3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayTester { const TEST_LOOP_SIZE = 1000000; public function go() { $start = microtime(true); for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $test = $this->getTest(); $someVal = $test[$a]; } echo 'Pass by copy: ' . (microtime(true) - $start) . ' sec<br>'; $start = microtime(true); for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $test = &$this->getTestByRef(); $someVal = $test[$a]; } echo 'Pass by reference: ' . (microtime(true) - $start) . ' sec<br>'; } private $_test; private function getTest() { if(!$this->_test) { for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $this->_test[$a]=md5($a); } } return $this->_test; } private $_testByRef; private function &getTestByRef() { if(!$this->_testByRef) { for($a = 0; $a<=self::TEST_LOOP_SIZE;++$a) { $this->_testByRef[$a]=md5($a); } } return $this->_testByRef; } } $tester = new ArrayTester(); $tester->go();

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)
7.2.00.1430.14067.17
7.1.70.0030.17565.17
7.1.60.0130.21165.56
7.1.50.0670.19464.83
7.1.00.0170.24770.18
7.0.201.7250.16563.27
7.0.140.0100.24069.96
7.0.60.0330.23068.06
7.0.50.0270.25365.81
7.0.40.0130.25335.92
7.0.30.0900.17735.96
7.0.20.0470.18735.93
7.0.10.0270.21335.93
7.0.00.0200.24735.94
5.6.280.0200.27085.79
5.6.210.0330.26785.22
5.6.200.0300.25082.88
5.6.190.0370.24785.05
5.6.180.3400.19785.08
5.6.170.0600.20085.09
5.6.160.0300.20784.96
5.6.150.0130.20382.85
5.6.140.0400.25382.83
5.6.130.0300.19382.84
5.6.120.0270.24085.80
5.6.110.0300.23385.73
5.6.100.0230.26385.71
5.6.90.0230.23085.57
5.6.80.0330.25785.09
5.6.70.4230.18085.21
5.5.350.0470.24785.14
5.5.340.0300.19782.65
5.5.330.0270.20084.71
5.5.320.0570.26084.79
5.5.310.0330.19784.79
5.5.300.0170.20382.59
5.5.290.0200.23782.59
5.5.280.0170.21785.46
5.5.270.0170.20385.46
5.5.260.0200.24785.34
5.5.250.0430.23085.16
5.5.240.0400.20384.77
5.4.450.0530.28384.08
5.4.440.0430.27784.02
5.4.430.0530.26383.88
5.4.420.0430.26383.99
5.4.410.0570.27383.77
5.4.400.0430.23383.70
5.4.390.0930.25083.70
5.4.380.0830.33083.22
5.4.370.1070.31083.40
5.4.360.0930.33083.43
5.4.350.1400.32083.26
5.4.340.1070.31783.43
5.4.320.0350.25077.19
5.4.310.0280.23077.18
5.4.300.0180.21877.19
5.4.290.0250.22277.18
5.4.280.0240.22277.08
5.4.270.0320.21177.08
5.4.260.0270.21977.09
5.4.250.0270.21577.08
5.4.240.0310.20977.08
5.4.230.0200.22377.07
5.4.220.0320.24177.07
5.4.210.0280.25377.07
5.4.200.0370.21177.07
5.4.190.0350.24777.07
5.4.180.0410.24077.07
5.4.170.0450.28177.08
5.4.160.0340.24977.08
5.4.150.0290.26177.07
5.4.140.0350.27376.75
5.4.130.0360.29776.74
5.4.120.0330.21276.70
5.4.110.0340.23476.70
5.4.100.0440.27876.70
5.4.90.0340.25576.70
5.4.80.0300.22776.70
5.4.70.0290.23076.69
5.4.60.0510.25776.69
5.4.50.0370.24976.70
5.4.40.0350.24276.69
5.4.30.0300.22176.68
5.4.20.0230.27376.68
5.4.10.0310.22176.68
5.4.00.0290.23676.17
5.3.290.0400.24376.10
5.3.280.0240.25976.02
5.3.270.0290.30276.04
5.3.260.0410.38876.04
5.3.250.0400.29476.04
5.3.240.0280.28376.04
5.3.230.0270.29976.03
5.3.220.0310.28376.00
5.3.210.0250.26376.00
5.3.200.0290.26976.00
5.3.190.0380.32476.00
5.3.180.0330.25576.00
5.3.170.0330.24976.00
5.3.160.0250.27676.00
5.3.150.0260.25876.00
5.3.140.0290.27075.98
5.3.130.0260.25575.98
5.3.120.0280.28075.98
5.3.110.0340.24975.98
5.3.100.0260.25775.47
5.3.90.0220.25475.45
5.3.80.0270.24776.06
5.3.70.0240.24575.44
5.3.60.0270.27075.43
5.3.50.0280.27875.37
5.3.40.0250.26675.91
5.3.30.0230.26975.34
5.3.20.0320.23575.12
5.3.10.0280.28675.08
5.3.00.0280.25075.07
5.2.170.0210.29572.90
5.2.160.0260.28972.91
5.2.150.0260.29472.91
5.2.140.0290.27972.91
5.2.130.0300.31372.86
5.2.120.0330.28672.86
5.2.110.0220.30372.87
5.2.100.0260.29672.86
5.2.90.0200.31372.87
5.2.80.0340.33472.85
5.2.70.0350.32172.86
5.2.60.0280.30772.81
5.2.50.0250.33072.72
5.2.40.0210.32572.70
5.2.30.0280.32472.68
5.2.20.0460.88972.66
5.2.10.0600.78272.57
5.2.00.0591.949165.84
5.1.60.0961.917216.71
5.1.50.0971.914221.65
5.1.40.0791.920215.10
5.1.30.1121.892191.16
5.1.20.1131.899210.92
5.1.10.1101.898180.92
5.1.00.1111.909175.34
5.0.50.0961.917188.84
5.0.40.0751.934203.34
5.0.30.0821.929190.00
5.0.20.0731.939203.95
5.0.10.0871.924208.66
5.0.00.0671.942199.34
4.4.90.0020.0164.78
4.4.80.0030.0164.75
4.4.70.0040.0154.76
4.4.60.0040.0144.76
4.4.50.0030.0154.77
4.4.40.0030.0254.71
4.4.30.0020.0174.76
4.4.20.0030.0164.84
4.4.10.0040.0174.85
4.4.00.0040.0254.76
4.3.110.0010.0234.67
4.3.100.0010.0174.66
4.3.90.0040.0134.63
4.3.80.0070.0234.58
4.3.70.0000.0174.63
4.3.60.0050.0134.63
4.3.50.0040.0154.63
4.3.40.0020.0284.54
4.3.30.0020.0163.30
4.3.20.0000.0183.28
4.3.10.0050.0133.24
4.3.00.0070.01315.66

preferences:
30.69 ms | 401 KiB | 5 Q