3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayTester { const TEST_LOOP_SIZE = 100000; 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.4.10.0230.09633.03
7.4.00.0150.12133.35
7.3.130.0200.10433.28
7.3.120.0200.09933.01
7.3.110.0180.11833.18
7.3.100.0170.07633.26
7.3.90.0120.08233.22
7.3.80.0170.08733.06
7.3.70.0150.07732.91
7.3.60.0140.08533.02
7.3.50.0150.08533.13
7.3.40.0150.08332.99
7.3.30.0200.08133.18
7.3.20.0120.07536.63
7.3.10.0130.07036.66
7.3.00.0120.07436.71
7.2.260.0220.11433.39
7.2.250.0200.12733.41
7.2.240.0270.08033.32
7.2.230.0230.09133.26
7.2.220.0200.11033.41
7.2.210.0150.09033.31
7.2.200.0210.09133.15
7.2.190.0120.10833.27
7.2.180.0170.09733.34
7.2.170.0120.09333.26
7.2.160.0180.09033.44
7.2.150.0100.08336.87
7.2.140.0080.09136.93
7.2.130.0120.08536.89
7.2.120.0020.09036.98
7.2.110.0060.08636.76
7.2.100.0130.08036.90
7.2.90.0130.09837.00
7.2.80.0070.09036.97
7.2.70.0050.09236.74
7.2.60.0070.08437.04
7.2.50.0150.07736.90
7.2.40.0080.10836.86
7.2.30.0030.10136.82
7.2.20.0100.11336.85
7.2.10.0070.09636.76
7.2.00.0060.10037.64
7.1.330.0120.12235.75
7.1.320.0080.12435.87
7.1.310.0050.12035.89
7.1.300.0070.11835.87
7.1.290.0030.12135.71
7.1.280.0070.12035.63
7.1.270.0050.13035.71
7.1.260.0070.11835.73
7.1.250.0150.12935.88
7.1.240.0150.11635.94
7.1.230.0070.12035.91
7.1.220.0070.12035.76
7.1.210.0080.11635.80
7.1.200.0080.13435.77
7.1.190.0080.12035.82
7.1.180.0100.11735.75
7.1.170.0130.13235.88
7.1.160.0050.12835.81
7.1.150.0050.12035.87
7.1.140.0080.13635.80
7.1.130.0030.12635.81
7.1.120.0000.12735.70
7.1.110.0050.13835.92
7.1.100.0120.12535.73
7.1.90.0030.12335.86
7.1.80.0080.12235.88
7.1.70.0090.10236.28
7.1.60.0090.12836.25
7.1.50.0130.10336.16
7.1.40.0100.13135.83
7.1.30.0030.12235.73
7.1.20.0130.11735.91
7.1.10.0100.12835.74
7.1.00.0130.15537.82
7.0.330.0070.12135.48
7.0.320.0020.12535.52
7.0.310.0070.12035.61
7.0.300.0050.13635.26
7.0.290.0050.12635.55
7.0.280.0030.12735.28
7.0.270.0030.12635.53
7.0.260.0070.14335.36
7.0.250.0150.12835.39
7.0.240.0120.11735.47
7.0.230.0070.12535.49
7.0.220.0030.12035.43
7.0.210.0080.12335.42
7.0.200.0220.11635.97
7.0.190.0130.11635.44
7.0.180.0070.12535.43
7.0.170.0100.11835.54
7.0.160.0100.11335.46
7.0.150.0080.14535.35
7.0.140.0070.14837.68
7.0.130.0070.13635.65
7.0.120.0130.12435.56
7.0.110.0070.13435.52
7.0.100.0030.12735.23
7.0.90.0070.12435.58
7.0.80.0050.15335.54
7.0.70.0030.13835.41
7.0.60.0060.14836.45
7.0.50.0090.14035.54
7.0.40.0080.12224.52
7.0.30.0250.13624.62
7.0.20.0200.14624.68
7.0.10.0090.14624.57
7.0.00.0100.13824.68
5.6.400.0220.22453.47
5.6.390.0200.23653.78
5.6.380.0230.23253.53
5.6.370.0150.23953.69
5.6.360.0130.24453.59
5.6.350.0320.22353.55
5.6.340.0250.23753.68
5.6.330.0200.23553.71
5.6.320.0270.23653.69
5.6.310.0200.22553.64
5.6.300.0240.23653.67
5.6.290.0200.24653.45
5.6.280.0180.24455.79
5.6.270.0360.21153.50
5.6.260.0200.23753.22
5.6.250.0170.24053.43
5.6.240.0230.24153.57
5.6.230.0250.26453.73
5.6.220.0220.26053.47
5.6.210.0110.21855.58
5.6.200.0200.21354.66
5.6.190.0210.21355.46
5.6.180.1330.23055.58
5.6.170.0320.23855.29
5.6.160.0300.21755.48
5.6.150.0270.20554.74
5.6.140.0190.23454.63
5.6.130.0250.21354.60
5.6.120.0130.23655.65
5.6.110.0180.25955.55
5.6.100.0200.23055.70
5.6.90.0170.25855.51
5.6.80.0190.22855.44
5.6.70.0200.22355.49
5.6.60.0230.23653.39
5.6.50.0380.23353.39
5.6.40.0150.23853.29
5.6.30.0250.22953.43
5.6.20.0250.25553.48
5.6.10.0200.23553.30
5.6.00.0230.25753.29
5.5.380.0230.22653.35
5.5.370.0220.22653.53
5.5.360.0220.23153.40
5.5.350.0190.23855.40
5.5.340.0200.25254.41
5.5.330.0230.25355.55
5.5.320.0330.22355.39
5.5.310.0220.23555.38
5.5.300.0210.24054.58
5.5.290.0200.27054.54
5.5.280.0190.24955.40
5.5.270.0250.23555.63
5.5.260.0280.23955.54
5.5.250.0170.23455.40
5.5.240.0300.24555.31
5.5.230.0120.26453.32
5.5.220.0270.23653.33
5.5.210.0230.25253.41
5.5.200.0270.23853.50
5.5.190.0220.28953.26
5.5.180.0250.27153.36
5.5.170.0200.25653.21
5.5.160.0200.29153.29
5.5.150.0300.26953.27
5.5.140.0200.22353.47
5.5.130.0260.24353.13
5.5.120.0270.22953.24
5.5.110.0180.25953.15
5.5.100.0230.26953.25
5.5.90.0200.26753.44
5.5.80.0270.24153.67
5.5.70.0250.21653.34
5.5.60.0130.24953.20
5.5.50.0200.22153.28
5.5.40.0180.26953.24
5.5.30.0250.23053.23
5.5.20.0170.24953.44
5.5.10.0220.21953.19
5.5.00.0300.25153.13
5.4.450.0280.26453.06
5.4.440.0300.26452.80
5.4.430.0220.21953.11
5.4.420.0280.24552.97
5.4.410.0310.25552.79
5.4.400.0290.22352.75
5.4.390.0200.24352.78
5.4.380.0370.26752.66
5.4.370.0420.25652.60
5.4.360.0380.25552.67
5.4.350.0480.27052.57
5.4.340.0410.25452.69
5.4.330.0180.25450.22
5.4.320.0230.24450.65
5.4.310.0150.25850.57
5.4.300.0120.23650.60
5.4.290.0190.24150.57
5.4.280.0140.21850.56
5.4.270.0220.23850.45
5.4.260.0170.23650.46
5.4.250.0280.22150.52
5.4.240.0260.22950.42
5.4.230.0270.23250.66
5.4.220.0210.26250.53
5.4.210.0170.23950.61
5.4.200.0210.22550.58
5.4.190.0180.26350.53
5.4.180.0210.21350.46
5.4.170.0200.25650.51
5.4.160.0250.24150.43
5.4.150.0150.23450.54
5.4.140.0130.26150.54
5.4.130.0140.27550.53
5.4.120.0170.21250.41
5.4.110.0170.21950.56
5.4.100.0160.26050.44
5.4.90.0200.21650.44
5.4.80.0200.23050.29
5.4.70.0130.23150.51
5.4.60.0230.21950.47
5.4.50.0220.22350.48
5.4.40.0210.21950.45
5.4.30.0210.24850.37
5.4.20.0230.23250.44
5.4.10.0170.24450.57
5.4.00.0150.21850.26
5.3.290.0170.24851.19
5.3.280.0270.23651.12
5.3.270.0210.25451.13
5.3.260.0170.28951.12
5.3.250.0160.24751.13
5.3.240.0180.25851.13
5.3.230.0220.24751.12
5.3.220.0170.24251.09
5.3.210.0180.27051.08
5.3.200.0170.24251.08
5.3.190.0180.24251.09
5.3.180.0200.23651.08
5.3.170.0180.28051.08
5.3.160.0150.25751.08
5.3.150.0190.24451.08
5.3.140.0190.27351.08
5.3.130.0270.23251.45
5.3.120.0190.23851.06
5.3.110.0150.29251.06
5.3.100.0230.23050.55
5.3.90.0180.23650.54
5.3.80.0200.25950.52
5.3.70.0160.25650.52
5.3.60.0210.23950.51
5.3.50.0210.25350.46
5.3.40.0260.24850.46
5.3.30.0180.33450.43
5.3.20.0190.27450.20
5.3.10.0270.24550.16
5.3.00.0220.25250.15
5.2.170.0220.26146.11
5.2.160.0240.40846.11
5.2.150.0340.57446.11
5.2.140.0330.47346.11
5.2.130.0230.29246.07
5.2.120.0260.27846.07
5.2.110.0200.25346.07
5.2.100.0160.27046.07
5.2.90.0180.29346.07
5.2.80.0160.28546.06
5.2.70.0160.27946.06
5.2.60.0130.32446.02
5.2.50.0210.32745.91
5.2.40.0170.33945.89
5.2.30.0310.28946.12
5.2.20.0411.00746.11
5.2.10.0500.72146.02
5.2.00.0240.72045.88
5.1.60.0450.61658.74
5.1.50.0300.58358.74
5.1.40.0370.63758.72
5.1.30.0330.77859.07
5.1.20.0340.86159.08
5.1.10.0340.94358.82
5.1.00.0440.77758.81
5.0.50.0240.82057.29
5.0.40.0270.64557.15
5.0.30.0240.67756.97
5.0.20.0250.65556.93
5.0.10.0130.66656.91
5.0.00.0240.74756.91
4.4.90.0030.0204.78
4.4.80.0030.0164.76
4.4.70.0040.0164.76
4.4.60.0040.0144.75
4.4.50.0030.0164.77
4.4.40.0000.0284.70
4.4.30.0030.0154.76
4.4.20.0020.0164.84
4.4.10.0020.0164.85
4.4.00.0030.0254.76
4.3.110.0020.0164.67
4.3.100.0020.0184.66
4.3.90.0030.0174.64
4.3.80.0050.0314.59
4.3.70.0020.0224.63
4.3.60.0030.0214.63
4.3.50.0050.0214.63
4.3.40.0010.0264.54
4.3.30.0020.0163.30
4.3.20.0020.0163.28
4.3.10.0000.0183.24
4.3.00.0100.01315.66

preferences:
34.29 ms | 401 KiB | 5 Q