<?php
//https://github.com/php/php-src/blob/master/Zend/micro_bench.php
function hallo() {}
function hallo2() {}
function simpleucall($n) { for ($i = 0; $i < $n; $i++) hallo(); }
function simpleudcall($n) { for ($i = 0; $i < $n; $i++) hallo2(); }
function simpleicall($n) { for ($i = 0; $i < $n; $i++) func_num_args(); }
define('TEST', null);
function read_const($n) { for ($i = 0; $i < $n; ++$i) $x = TEST; }
function read_auto_global($n) { for ($i = 0; $i < $n; ++$i) $x = $_GET; }
$g_var = 0;
function read_global_var($n) { for ($i = 0; $i < $n; ++$i) $x = $GLOBALS['g_var']; }
function read_hash($n) { $hash = array('test' => 0); for ($i = 0; $i < $n; ++$i) $x = $hash['test'];}
function read_str_offset($n) { $str = "test"; for ($i = 0; $i < $n; ++$i) $x = $str[1]; }
function issetor($n) { $val = array(0,1,2,3,4,5,6,7,8,9); for ($i = 0; $i < $n; ++$i) $x = $val ?: null; }
function issetor2($n) { $f = false; $j = 0; for ($i = 0; $i < $n; ++$i) $x = $f ?: $j + 1; }
function ternary($n) { $val = array(0,1,2,3,4,5,6,7,8,9); $f = false; for ($i = 0; $i < $n; ++$i) $x = $f ? null : $val; }
function ternary2($n) { $f = false; $j = 0; for ($i = 0; $i < $n; ++$i) $x = $f ? $f : $j + 1; }
/*****/
function getmicrotime() { $t = gettimeofday(); return ($t['sec'] + $t['usec'] / 1000000);}
const N = 50000;
simpleucall(N);
simpleudcall(N);
simpleicall(N);
read_const(N);
read_auto_global(N);
read_global_var(N);
read_hash(N);
read_str_offset(N);
issetor(N);
issetor2(N);
ternary(N);
ternary2(N);
- Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.30, 7.4.0 - 7.4.24, 8.0.0 - 8.0.11
- Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
- Parse error: syntax error, unexpected ':' in /in/kuO9u on line 22
Process exited with code 255. - Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
- Parse error: parse error, unexpected ':' in /in/kuO9u on line 22
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Parse error: parse error in /in/kuO9u on line 22
Process exited with code 255.
preferences:
236.09 ms | 401 KiB | 375 Q