3v4l.org

run code in 300+ PHP versions simultaneously
<?php //https://github.com/php/php-src/blob/master/Zend/micro_bench.php function hallo() { } function simpleucall($n) { for ($i = 0; $i < $n; $i++) hallo(); } function simpleudcall($n) { for ($i = 0; $i < $n; $i++) hallo2(); } function hallo2() { } function simpleicall($n) { for ($i = 0; $i < $n; $i++) func_num_args(); } class Foo { static $a = 0; public $b = 0; const TEST = 0; static function read_static($n) { for ($i = 0; $i < $n; ++$i) { $x = self::$a; } } static function write_static($n) { for ($i = 0; $i < $n; ++$i) { self::$a = 0; } } static function isset_static($n) { for ($i = 0; $i < $n; ++$i) { $x = isset(self::$a); } } static function empty_static($n) { for ($i = 0; $i < $n; ++$i) { $x = empty(self::$a); } } static function f() { } static function call_static($n) { for ($i = 0; $i < $n; ++$i) { self::f(); } } function read_prop($n) { for ($i = 0; $i < $n; ++$i) { $x = $this->b; } } function write_prop($n) { for ($i = 0; $i < $n; ++$i) { $this->b = 0; } } function assign_add_prop($n) { for ($i = 0; $i < $n; ++$i) { $this->b += 2; } } function pre_inc_prop($n) { for ($i = 0; $i < $n; ++$i) { ++$this->b; } } function pre_dec_prop($n) { for ($i = 0; $i < $n; ++$i) { --$this->b; } } function post_inc_prop($n) { for ($i = 0; $i < $n; ++$i) { $this->b++; } } function post_dec_prop($n) { for ($i = 0; $i < $n; ++$i) { $this->b--; } } function isset_prop($n) { for ($i = 0; $i < $n; ++$i) { $x = isset($this->b); } } function empty_prop($n) { for ($i = 0; $i < $n; ++$i) { $x = empty($this->b); } } function g() { } function call($n) { for ($i = 0; $i < $n; ++$i) { $this->g(); } } function read_const($n) { for ($i = 0; $i < $n; ++$i) { $x = $this::TEST; } } } function read_static($n) { for ($i = 0; $i < $n; ++$i) { $x = Foo::$a; } } function write_static($n) { for ($i = 0; $i < $n; ++$i) { Foo::$a = 0; } } function isset_static($n) { for ($i = 0; $i < $n; ++$i) { $x = isset(Foo::$a); } } function empty_static($n) { for ($i = 0; $i < $n; ++$i) { $x = empty(Foo::$a); } } function call_static($n) { for ($i = 0; $i < $n; ++$i) { Foo::f(); } } function create_object($n) { for ($i = 0; $i < $n; ++$i) { $x = new Foo(); } } 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 empty_loop($n) { for ($i = 0; $i < $n; ++$i) { } } function getmicrotime() { $t = gettimeofday(); return ($t['sec'] + $t['usec'] / 1000000); } function start_test() { ob_start(); return getmicrotime(); } function end_test($start, $name, $overhead = null) { global $total; global $last_time; $end = getmicrotime(); ob_end_clean(); $last_time = $end-$start; $total += $last_time; $num = number_format($last_time,3); $pad = str_repeat(" ", 24-strlen($name)-strlen($num)); if (is_null($overhead)) { echo $name.$pad.$num."\n"; } else { $num2 = number_format($last_time - $overhead,3); echo $name.$pad.$num." ".$num2."\n"; } ob_start(); return getmicrotime(); } function total() { global $total; $pad = str_repeat("-", 24); echo $pad."\n"; $num = number_format($total,3); $pad = str_repeat(" ", 24-strlen("Total")-strlen($num)); echo "Total".$pad.$num."\n"; } const N = 50000; $t0 = $t = start_test(); empty_loop(N); $t = end_test($t, 'empty_loop'); $overhead = $last_time; simpleucall(N); $t = end_test($t, 'func()', $overhead); simpleudcall(N); $t = end_test($t, 'undef_func()', $overhead); simpleicall(N); $t = end_test($t, 'int_func()', $overhead); Foo::read_static(N); $t = end_test($t, '$x = self::$x', $overhead); Foo::write_static(N); $t = end_test($t, 'self::$x = 0', $overhead); Foo::isset_static(N); $t = end_test($t, 'isset(self::$x)', $overhead); Foo::empty_static(N); $t = end_test($t, 'empty(self::$x)', $overhead); read_static(N); $t = end_test($t, '$x = Foo::$x', $overhead); write_static(N); $t = end_test($t, 'Foo::$x = 0', $overhead); isset_static(N); $t = end_test($t, 'isset(Foo::$x)', $overhead); empty_static(N); $t = end_test($t, 'empty(Foo::$x)', $overhead); Foo::call_static(N); $t = end_test($t, 'self::f()', $overhead); call_static(N); $t = end_test($t, 'Foo::f()', $overhead); $x = new Foo(); $x->read_prop(N); $t = end_test($t, '$x = $this->x', $overhead); $x->write_prop(N); $t = end_test($t, '$this->x = 0', $overhead); $x->assign_add_prop(N); $t = end_test($t, '$this->x += 2', $overhead); $x->pre_inc_prop(N); $t = end_test($t, '++$this->x', $overhead); $x->pre_dec_prop(N); $t = end_test($t, '--$this->x', $overhead); $x->post_inc_prop(N); $t = end_test($t, '$this->x++', $overhead); $x->post_dec_prop(N); $t = end_test($t, '$this->x--', $overhead); $x->isset_prop(N); $t = end_test($t, 'isset($this->x)', $overhead); $x->empty_prop(N); $t = end_test($t, 'empty($this->x)', $overhead); $x->call(N); $t = end_test($t, '$this->f()', $overhead); $x->read_const(N); $t = end_test($t, '$x = Foo::TEST', $overhead); create_object(N); $t = end_test($t, 'new Foo()', $overhead); read_const(N); $t = end_test($t, '$x = TEST', $overhead); read_auto_global(N); $t = end_test($t, '$x = $_GET', $overhead); read_global_var(N); $t = end_test($t, '$x = $GLOBALS[\'v\']', $overhead); read_hash(N); $t = end_test($t, '$x = $hash[\'v\']', $overhead); read_str_offset(N); $t = end_test($t, '$x = $str[0]', $overhead); issetor(N); $t = end_test($t, '$x = $a ?: null', $overhead); issetor2(N); $t = end_test($t, '$x = $f ?: tmp', $overhead); ternary(N); $t = end_test($t, '$x = $f ? $f : $a', $overhead); ternary2(N); $t = end_test($t, '$x = $f ? $f : tmp', $overhead); total($t0, "Total");

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.70.0100.04316.75
8.3.60.0130.03416.63
8.3.50.0100.04316.62
8.3.40.0070.03619.04
8.3.30.0130.04019.01
8.3.20.0100.01319.15
8.3.10.0000.02319.24
8.3.00.0080.01619.63
8.2.180.0070.04617.00
8.2.170.0100.04722.96
8.2.160.0160.04219.21
8.2.150.0040.02124.18
8.2.140.0060.01824.66
8.2.130.0070.01626.16
8.2.120.0060.01621.09
8.2.110.0100.02919.54
8.2.100.0000.03118.16
8.2.90.0060.02219.82
8.2.80.0030.02418.00
8.2.70.0060.02218.00
8.2.60.0000.03018.28
8.2.50.0000.03118.07
8.2.40.0070.02019.61
8.2.30.0000.03018.23
8.2.20.0070.02718.11
8.2.10.0000.02718.01
8.2.00.0090.02218.18
8.1.280.0060.03925.92
8.1.270.0070.01723.99
8.1.260.0070.01726.35
8.1.250.0070.01728.09
8.1.240.0070.03122.73
8.1.230.0030.02721.07
8.1.220.0000.02717.93
8.1.210.0000.02719.04
8.1.200.0060.02317.84
8.1.190.0030.02417.72
8.1.180.0060.02218.10
8.1.170.0000.02719.07
8.1.160.0030.02319.32
8.1.150.0070.02018.96
8.1.140.0030.02417.87
8.1.130.0060.02219.33
8.1.120.0070.02017.74
8.1.110.0000.02717.77
8.1.100.0030.02317.81
8.1.90.0030.02317.79
8.1.80.0070.02017.85
8.1.70.0030.02317.75
8.1.60.0030.03417.90
8.1.50.0100.02617.79
8.1.40.0070.03117.74
8.1.30.0030.03317.88
8.1.20.0000.03818.00
8.1.10.0030.03317.84
8.1.00.0030.03317.84
8.0.300.0000.02820.19
8.0.290.0040.02617.13
8.0.280.0000.02618.79
8.0.270.0000.02717.48
8.0.260.0000.02717.20
8.0.250.0070.02117.20
8.0.240.0000.02817.27
8.0.230.0000.03217.23
8.0.220.0000.02717.31
8.0.210.0000.02717.27
8.0.200.0030.02517.34
8.0.190.0000.03717.30
8.0.180.0030.03917.29
8.0.170.0090.03217.30
8.0.160.0000.03617.21
8.0.150.0030.03517.19
8.0.140.0020.04317.13
8.0.130.0000.03413.72
8.0.120.0130.03217.13
8.0.110.0000.03717.09
8.0.100.0030.03317.27
8.0.90.0000.03617.13
8.0.80.0060.04317.22
8.0.70.0000.03617.29
8.0.60.0040.03617.24
8.0.50.0100.03017.22
8.0.30.0100.03617.60
8.0.20.0070.04717.37
8.0.10.0000.03617.42
8.0.00.0140.05317.02
7.4.330.0000.02613.23
7.4.320.0030.02616.93
7.4.300.0060.02516.91
7.4.290.0100.03416.95
7.4.280.0000.03916.93
7.4.270.0030.03416.91
7.4.260.0070.03013.50
7.4.250.0070.03316.86
7.4.240.0000.03816.76
7.4.230.0060.03216.82
7.4.220.0070.05716.83
7.4.210.0030.05016.80
7.4.200.0030.03416.80
7.4.190.0000.04017.07
7.4.160.0120.04016.81
7.4.150.0070.04816.93
7.4.140.0030.07517.86
7.4.130.0100.04916.92
7.4.120.0060.04716.77
7.4.110.0160.06716.78
7.4.100.0110.05316.75
7.4.90.0090.04516.70
7.4.80.0060.05319.39
7.4.70.0040.05216.95
7.4.60.0130.03916.80
7.4.50.0000.02916.79
7.4.40.0080.03916.67
7.4.30.0060.04816.92
7.4.10.0100.05015.27
7.4.00.0070.05014.97
7.3.330.0000.03913.46
7.3.320.0000.03713.66
7.3.310.0030.03516.50
7.3.300.0070.03116.69
7.3.290.0090.04916.72
7.3.280.0100.04916.69
7.3.270.0090.05017.00
7.3.260.0030.06316.80
7.3.240.0100.05416.89
7.3.230.0160.04116.93
7.3.210.0140.04516.72
7.3.200.0140.06516.97
7.3.190.0070.05016.91
7.3.180.0160.04516.80
7.3.170.0110.04816.85
7.3.160.0130.04316.76
7.3.130.0130.05614.88
7.3.120.0060.05615.17
7.3.110.0080.05314.97
7.3.100.0020.04614.88
7.3.90.0070.05415.09
7.3.80.0050.04815.08
7.3.70.0100.03815.09
7.3.60.0070.04714.95
7.3.50.0050.04615.02
7.3.40.0050.04315.03
7.3.30.0070.03914.96
7.3.20.0030.04616.71
7.3.10.0030.04516.58
7.3.00.0080.04216.68
7.2.330.0130.05116.89
7.2.320.0130.05317.19
7.2.310.0120.06417.19
7.2.300.0160.06516.87
7.2.290.0130.05216.97
7.2.260.0070.06415.32
7.2.250.0100.05115.41
7.2.240.0080.05215.46
7.2.230.0060.04415.31
7.2.220.0060.04915.13
7.2.210.0070.04615.42
7.2.200.0100.04315.24
7.2.190.0030.05115.25
7.2.180.0050.04415.20
7.2.170.0020.05015.31
7.2.160.0130.04215.34
7.2.150.0100.03916.93
7.2.140.0130.03916.76
7.2.130.0070.04717.05
7.2.120.0070.04417.06
7.2.110.0070.04816.97
7.2.100.0050.04716.92
7.2.90.0030.04617.04
7.2.80.0100.03716.90
7.2.70.0030.04617.15
7.2.60.0840.05416.42
7.2.50.0080.04516.91
7.2.40.0070.04417.15
7.2.30.0060.04517.10
7.2.20.0080.04016.87
7.2.10.0080.04216.89
7.2.00.0050.04417.76
7.1.330.0050.09415.75
7.1.320.0050.09815.68
7.1.310.0050.09415.89
7.1.300.0030.09715.72
7.1.290.0080.09915.51
7.1.280.0060.08915.83
7.1.270.0070.09415.71
7.1.260.0070.09115.78
7.1.250.0080.09415.89
7.1.240.0030.10015.77
7.1.230.0030.10315.72
7.1.220.0030.09015.66
7.1.210.0030.10215.88
7.1.200.0060.07615.86
7.1.190.0050.10615.79
7.1.180.0020.09815.93
7.1.170.0050.11015.66
7.1.160.0050.09315.77
7.1.150.0030.09615.85
7.1.140.0080.09115.85
7.1.130.0020.10416.02
7.1.120.0070.09815.69
7.1.110.0070.09615.84
7.1.100.0040.08416.79
7.1.90.0080.08815.74
7.1.80.0050.09715.90
7.1.70.0070.08116.29
7.1.60.0090.08417.02
7.1.50.0020.08316.27
7.1.40.0070.09115.87
7.1.30.0080.09015.77
7.1.20.0030.10515.57
7.1.10.0030.09715.58
7.1.00.0070.08317.96
7.0.330.0050.09415.26
7.0.320.0050.08915.50
7.0.310.0070.09315.36
7.0.300.0120.10615.56
7.0.290.0030.10115.48
7.0.280.0050.10115.21
7.0.270.0080.10215.43
7.0.260.0030.09815.34
7.0.250.0080.09415.49
7.0.240.0050.10315.60
7.0.230.0050.09815.42
7.0.220.0020.09715.31
7.0.210.0050.10015.36
7.0.200.0040.08015.97
7.0.190.0100.08915.55
7.0.180.0070.09615.25
7.0.170.0020.09815.29
7.0.160.0020.10815.28
7.0.150.0070.09115.39
7.0.140.0060.10617.59
7.0.130.0050.10515.30
7.0.120.0070.10817.67
7.0.110.0100.09315.47
7.0.100.0030.09117.04
7.0.90.0030.11417.01
7.0.80.0030.10917.04
7.0.70.0080.10016.98
7.0.60.0030.09316.91
7.0.50.0090.09717.27
7.0.40.0070.10415.83
7.0.30.0070.10315.58
7.0.20.0060.10315.79
7.0.10.0040.09915.63
7.0.00.0070.10515.74
5.6.400.0000.22014.70
5.6.390.0070.21414.58
5.6.380.0030.21714.61
5.6.370.0030.23314.74
5.6.360.0100.21214.54
5.6.350.0030.22614.66
5.6.340.0030.23214.56
5.6.330.0100.21414.56
5.6.320.0070.22314.69
5.6.310.0080.21714.61
5.6.300.0070.21714.62
5.6.290.0050.21514.48
5.6.280.0070.21016.88
5.6.270.0070.22414.71
5.6.260.0050.23014.46
5.6.250.0070.20616.62
5.6.240.0030.19916.65
5.6.230.0090.20716.71
5.6.220.0130.20816.69
5.6.210.0060.20916.65
5.6.200.0090.19716.82
5.6.190.0030.20416.81
5.6.180.0040.19716.76
5.6.170.0080.21016.79
5.6.160.0080.21116.79
5.6.150.0040.20016.61
5.6.140.0170.20216.78
5.6.130.0100.20516.80
5.6.120.0040.21616.89
5.6.110.0060.18716.66
5.6.100.0080.20316.83
5.6.90.0060.22516.79
5.6.80.0040.21116.60
5.6.70.0060.21516.49
5.6.60.0080.20216.49
5.6.50.0100.20116.44
5.6.40.0090.19016.52
5.6.30.0090.20116.41
5.6.20.0080.21416.29
5.6.10.0040.19616.57
5.6.00.0060.20416.52
5.5.380.0060.18615.64
5.5.370.0080.20515.60
5.5.360.0060.19215.46
5.5.350.0060.20315.67
5.5.340.0040.20915.77
5.5.330.0060.21315.68
5.5.320.0080.20115.56
5.5.310.0070.20115.70
5.5.300.0040.20315.81
5.5.290.0070.21115.73
5.5.280.0030.22415.70
5.5.270.0020.21215.58
5.5.260.0040.19215.58
5.5.250.0060.22015.61
5.5.240.0060.19215.51
5.5.230.0090.21315.50
5.5.220.0070.21315.51
5.5.210.0020.19915.46
5.5.200.0070.20515.50
5.5.190.0040.20415.48
5.5.180.0080.20815.40
5.5.170.0030.22312.62
5.5.160.0080.20115.45
5.5.150.0100.20615.35
5.5.140.0030.21415.39
5.5.130.0090.19015.29
5.5.120.0060.19415.42
5.5.110.0060.19615.49
5.5.100.0030.20015.36
5.5.90.0020.20315.12
5.5.80.0030.20615.38
5.5.70.0080.20815.26
5.5.60.0060.20915.47
5.5.50.0030.20515.39
5.5.40.0060.20215.28
5.5.30.0040.21615.33
5.5.20.0070.22215.13
5.5.10.0070.19515.35
5.5.00.0040.19415.40
5.4.450.0060.20014.16
5.4.440.0090.21214.14
5.4.430.0070.19914.15
5.4.420.0030.21314.15
5.4.410.0070.19614.04
5.4.400.0040.21213.99
5.4.390.0030.20113.74
5.4.380.0080.20913.79
5.4.370.0040.20913.90
5.4.360.0090.20313.91
5.4.350.0060.21413.85
5.4.340.0060.21613.85
5.4.330.0000.23511.33
5.4.320.0060.20813.79
5.4.310.0020.21013.99
5.4.300.0040.20813.86
5.4.290.0090.18413.99
5.4.280.0040.19413.83
5.4.270.0080.19313.82
5.4.260.0080.19913.78
5.4.250.0060.18913.99
5.4.240.0020.19513.86
5.4.230.0060.21613.98
5.4.220.0030.20213.87
5.4.210.0080.19514.11
5.4.200.0080.20913.85
5.4.190.0060.20913.84
5.4.180.0080.19813.84
5.4.170.0060.20213.85
5.4.160.0020.19813.89
5.4.150.0020.19113.82
5.4.140.0070.18113.19
5.4.130.0090.18313.11
5.4.120.0010.19412.96
5.4.110.0040.19113.08
5.4.100.0020.20012.99
5.4.90.0070.18313.07
5.4.80.0080.18912.90
5.4.70.0070.19412.89
5.4.60.0170.17713.09
5.4.50.0020.20213.07
5.4.40.0030.20513.04
5.4.30.0040.18412.96
5.4.20.0040.21113.07
5.4.10.0030.22313.04
5.4.00.0100.21312.91
5.3.290.0030.33612.47
5.3.280.0070.32912.32
5.3.270.0060.32712.18
5.3.260.0030.32912.22
5.3.250.0070.30312.19
5.3.240.0030.32012.30
5.3.230.0040.33312.24
5.3.220.0020.29412.14
5.3.210.0080.32112.03
5.3.200.0010.29612.15
5.3.190.0130.31612.11
5.3.180.0030.30712.25
5.3.170.0030.32212.21
5.3.160.0030.31512.16
5.3.150.0020.30212.23
5.3.140.0060.30712.01
5.3.130.0030.32112.22
5.3.120.0060.31812.09
5.3.110.0020.36112.16
5.3.100.0040.33312.01
5.3.90.0070.31312.08
5.3.80.0040.32111.89
5.3.70.0040.33312.06
5.3.60.0070.33711.98
5.3.50.0060.29511.93
5.3.40.0040.30412.02
5.3.30.0110.32611.95
5.3.20.0020.31911.83
5.3.10.0060.31311.72
5.3.00.0020.31111.65

preferences:
44.56 ms | 401 KiB | 5 Q