The Computer Language
24.11 Benchmarks Game

too simple PHP program

source code

<?php
/* The Computer Language Benchmarks Game
   https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
*/

// mtime side-effect   
$f = fopen("./one", "w"); fclose($f);
    
$n = $argv[1];
$sum = 0.0;
$flip = -1.0;
for ($i = 1 ; $i <= $n ; $i++) {    
    $flip *= -1.0;        
    $sum += $flip / (2*$i - 1);  
}
printf("%0.9f\n", ($sum*4.0));

// mtime side-effect   
$f = fopen("./two", "w"); fclose($f);
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
PHP 8.4.1 (cli)
(built: Nov 22 2024 14:22:47) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.1,
with Zend OPcache v8.4.1,
Copyright (c) Zend Technologies


 Sat, 23 Nov 2024 05:56:26 GMT

COMMAND LINE:
 /opt/src/php-8.4.1/bin/php -dzend_extension=/opt/src/php-8.4.1/lib/php/extensions/no-debug-non-zts-20240924/opcache.so -dopcache.enable_cli=1 -dopcache.jit_buffer_size=64M -n  toosimple.php 10000000000

PROGRAM OUTPUT:
3.141592653