3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('NUM_INSTANCES', 10); define('NUM_TESTS', 10000); class TestObject { public $a; public $b; public $c; public function __construct($a,$b,$c) { $this->a = $a; $this->b = $b; $this->c = $c; } } class Test { public function getObjects() { $a = array(); for ($i=0; $i<NUM_INSTANCES; $i++) $a[] = new TestObject('a','b','c'); return $a; } public function getArrays() { $a = array(); for ($i=0; $i<NUM_INSTANCES; $i++) $a[] = $this->buildArray('a', 'b', 'c'); return $a; } public function buildArray($a, $b, $c) { $array = array(); $array['a'] = $a; $array['b'] = $b; $array['c'] = $c; return $array; } public function useObject($o) { $a = $o->a; $b = $o->b; $o->c = 'xxx'; } public function useArray($o) { $a = $o['a']; $b = $o['b']; $o['c'] = 'xxx'; } } $test = new Test; // Benchmark with objects: $start = microtime(true); for ($i=0; $i<NUM_TESTS; $i++) { $x = $test->getObjects(); foreach ($x as $y) $test->useObject($y); } echo "\nObject time = " . (microtime(true)-$start) . "\n\n"; // Benchmark with arrays: $start = microtime(true); for ($i=0; $i<NUM_TESTS; $i++) { $x = $test->getArrays(); foreach ($x as $y) $test->useArray($y); } echo "\nArray time = " . (microtime(true)-$start) . "\n\n";

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)
5.5.100.0100.19811.38
5.5.90.0030.24211.13
5.5.80.0120.27611.07
5.5.70.0070.20911.28
5.5.60.0000.28711.16
5.5.50.0060.19311.29
5.5.40.0030.30111.18
5.5.30.0060.30411.18
5.5.20.0100.26511.20
5.5.10.0030.29911.19
5.5.00.0070.22311.16
5.4.260.0070.29111.13
5.4.250.0060.21711.24
5.4.240.0060.24211.16
5.4.230.0060.28610.88
5.4.220.0060.18711.17
5.4.210.0030.20210.86
5.4.200.0000.19511.20
5.4.190.0060.21211.11
5.4.180.0060.19511.43
5.4.170.0070.20611.18
5.4.160.0030.19411.18
5.4.150.0070.21211.01
5.4.140.0070.22710.96
5.4.130.0030.18911.27
5.4.120.0060.31211.26
5.4.110.0040.19911.26
5.4.100.0070.21911.23
5.4.90.0030.22011.21
5.4.80.0100.34111.36
5.4.70.0060.18211.16
5.4.60.0090.18611.30
5.4.50.0030.20811.23
5.4.40.0130.18711.13
5.4.30.0030.20611.25
5.4.20.0100.19211.31
5.4.10.0040.30611.32
5.4.00.0100.20611.00
5.3.280.0100.31810.37
5.3.270.0000.44710.66
5.3.260.0100.34210.77
5.3.250.0030.31710.74
5.3.240.0030.29910.36
5.3.230.0030.28110.66
5.3.220.0100.34110.64
5.3.210.0030.30610.29
5.3.200.0090.30110.58
5.3.190.0030.27910.50
5.3.180.0030.28210.82
5.3.170.0060.30210.57
5.3.160.0060.27210.81
5.3.150.0100.30410.82
5.3.140.0030.27410.41
5.3.130.0060.47710.70
5.3.120.0000.31410.66
5.3.110.0000.27910.54
5.3.100.0030.29510.48
5.3.90.0030.33810.54
5.3.80.0030.34910.60
5.3.70.0070.28410.41
5.3.60.0000.29810.57
5.3.50.0030.31210.75
5.3.40.0030.28010.63
5.3.30.0030.29010.74
5.3.20.0060.39810.62
5.3.10.0030.29710.13
5.3.00.0030.32610.37
5.2.170.0030.3659.49
5.2.160.0070.4569.66
5.2.150.0030.5609.64
5.2.140.0070.4029.59
5.2.130.0030.3939.25
5.2.120.0060.3969.61
5.2.110.0030.3669.61
5.2.100.0060.4219.61
5.2.90.0060.3519.23
5.2.80.0060.3819.54
5.2.70.0030.3969.30
5.2.60.0030.3539.29
5.2.50.0100.3509.16
5.2.40.0030.4049.53
5.2.30.0070.3799.43
5.2.20.0030.3949.34
5.2.10.0030.4229.18
5.2.00.0030.3599.23
5.1.60.0030.3968.93
5.1.50.0000.3828.93
5.1.40.0060.3768.93
5.1.30.0070.3608.93
5.1.20.0070.3728.93
5.1.10.0000.5708.93
5.1.00.0060.4468.93
5.0.50.0000.5638.93
5.0.40.0030.7408.93
5.0.30.0030.5348.93
5.0.20.0060.5678.93
5.0.10.0000.5388.93
5.0.00.0000.5638.93
4.4.90.0030.0038.93
4.4.80.0000.0048.93
4.4.70.0000.0058.93
4.4.60.0040.0048.93
4.4.50.0030.0038.93
4.4.40.0060.0008.93
4.4.30.0000.0048.93
4.4.20.0030.0038.93
4.4.10.0020.0028.93
4.4.00.0040.0008.93
4.3.110.0000.0068.93
4.3.100.0000.0048.93
4.3.90.0050.0008.93
4.3.80.0030.0038.93
4.3.70.0000.0068.93
4.3.60.0060.0008.93
4.3.50.0060.0008.93
4.3.40.0000.0058.93
4.3.30.0030.0028.93
4.3.20.0040.0008.93
4.3.10.0000.0058.93
4.3.00.0000.0058.93

preferences:
30.3 ms | 401 KiB | 5 Q