3v4l.org

run code in 300+ PHP versions simultaneously
<?php $values = range(1, 10000); $c = 0; $start = microtime(true); $l = count($values); $i = 0; while ($i < $l) { $c++; $i++; } $end = microtime(true); printf('while $i++ %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $l = count($values); for ($i = 0; $i < $l; $i++) { $c++; } $end = microtime(true); printf('for $i++ %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); foreach ($values as $val) { $c++; } $end = microtime(true); printf('foreach %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $value = reset($values); while ($value) { $c++; $value = next($values); } $end = microtime(true); printf('while reset, next %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); while ($val = current($values)) { $c++; next($values); } $end = microtime(true); printf('while current, next %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $value = current($values); do{ $c++; }while($value = next($values)); $end = microtime(true); printf('do while next %d iterations in %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); while ($values) { $c++; array_shift($values); } $end = microtime(true); printf('while array_shift %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL; $values = range(1, 10000); $c = 0; $start = microtime(true); $values = array_reverse($values); while ($values) { $c++; array_pop($values); } $end = microtime(true); printf('while array_pop %d iterations in: %f sec', $c, ($end - $start)); echo PHP_EOL;

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.0070.26515.70
7.4.00.0070.23415.77
7.3.130.0070.26315.50
7.3.120.0100.24215.55
7.3.110.0080.24115.45
7.3.100.0080.22415.62
7.3.90.0080.21615.51
7.3.80.0030.22815.38
7.3.70.0030.23315.55
7.3.60.0050.22615.42
7.3.50.0030.22115.47
7.3.40.0050.21715.29
7.3.30.0030.22715.24
7.3.20.0030.22916.75
7.3.10.0000.22816.75
7.3.00.0050.22216.57
7.2.260.0100.26215.86
7.2.250.0070.23615.48
7.2.240.0050.22715.78
7.2.230.0020.23215.90
7.2.220.0070.22715.71
7.2.210.0050.22715.68
7.2.200.0080.21615.69
7.2.190.0050.23415.80
7.2.180.0070.21515.73
7.2.170.0100.23315.61
7.2.160.0020.22615.62
7.2.150.0020.22216.71
7.2.140.0070.22916.85
7.2.130.0070.23116.89
7.2.120.0070.21916.86
7.2.110.0080.22616.93
7.2.100.0430.19216.21
7.2.90.0430.22716.17
7.2.80.0450.19416.10
7.2.70.0720.21416.37
7.2.60.0220.20016.32
7.2.50.0470.19416.34
7.2.40.0440.19716.31
7.2.30.0320.20416.25
7.2.20.0540.19416.25
7.2.10.0520.19816.26
7.2.00.0500.20816.33
7.1.330.0030.24015.63
7.1.320.0020.23515.75
7.1.310.0030.23215.51
7.1.300.0030.24715.91
7.1.290.0030.22915.67
7.1.280.0050.22515.73
7.1.270.0050.24715.74
7.1.260.0080.21815.71
7.1.250.0020.22815.70
7.1.240.0130.22015.88
7.1.230.0030.24815.84
7.1.220.0290.19315.20
7.1.210.0260.20415.00
7.1.200.0330.22314.83
7.1.190.0610.20715.01
7.1.180.0630.19714.98
7.1.170.0590.19514.97
7.1.160.0270.20014.95
7.1.150.0310.19515.08
7.1.140.0660.19715.00
7.1.130.0580.19715.01
7.1.120.0560.18715.00
7.1.110.0600.19514.90
7.1.100.0680.19415.09
7.1.90.0580.18915.02
7.1.80.0670.21015.09
7.1.70.0560.19815.03
7.1.60.0710.21126.93
7.1.50.0610.19827.06
7.1.40.0590.18826.88
7.1.30.0630.21026.93
7.1.20.0680.19026.89
7.1.10.0480.21214.94
7.1.00.0340.18914.90
7.0.330.0030.24115.07
7.0.320.0030.24015.05
7.0.310.0230.21014.76
7.0.300.0430.21714.87
7.0.290.0170.21414.65
7.0.280.0620.21714.76
7.0.270.0620.23414.80
7.0.260.0510.19814.83
7.0.250.0680.21614.62
7.0.240.0610.20014.87
7.0.230.0470.20114.80
7.0.220.0550.18414.91
7.0.210.0630.19114.79
7.0.200.0370.19014.87
7.0.190.0580.22814.89
7.0.180.0530.19614.74
7.0.170.0160.22415.02
7.0.160.0180.21714.83
7.0.150.0410.19514.91
7.0.140.0330.21214.65
7.0.130.0780.20314.91
7.0.120.0500.24214.71
7.0.110.0340.21714.94
7.0.100.0140.19714.82
7.0.90.0450.22314.93
7.0.80.0170.21314.82
7.0.70.0510.20814.84
7.0.60.0120.22614.88
7.0.50.0080.24614.98
7.0.40.0540.21113.82
7.0.30.0740.20313.99
7.0.20.0620.21513.86
7.0.10.0730.23513.80
7.0.00.0570.19813.83
5.6.400.0070.45117.46
5.6.390.0070.44517.33
5.6.380.0150.50217.38
5.6.370.0100.51117.17
5.6.360.0130.51717.19
5.6.350.0150.49317.39
5.6.340.0110.51417.01
5.6.330.0130.50417.35
5.6.320.0200.50317.18
5.6.310.0190.55617.45
5.6.300.0070.50317.15
5.6.290.0200.47817.15
5.6.280.0080.50316.96
5.6.270.0150.54517.05
5.6.260.0150.59717.09
5.6.250.0130.49017.19
5.6.240.0160.51117.12
5.6.230.0130.62017.11
5.6.220.0100.52117.29
5.6.210.0150.56217.35
5.6.200.0200.53517.19
5.6.190.0150.57417.20
5.6.180.0150.51117.27
5.6.170.0200.53017.13
5.6.160.0190.53317.12
5.6.150.0150.52517.33
5.6.140.0120.52017.30
5.6.130.0110.61617.34
5.6.120.0070.60017.21
5.6.110.0050.59417.35
5.6.100.0100.54117.22
5.6.90.0130.53017.24
5.6.80.0070.57517.06
5.6.70.0130.51417.27
5.6.60.0130.56517.30
5.6.50.0150.55017.34
5.6.40.0150.50817.12
5.6.30.0160.48617.08
5.6.20.0120.49217.17
5.6.10.0110.51417.08
5.6.00.0100.47517.04
5.5.380.0130.84513.83
5.5.370.0130.84514.05
5.5.360.0070.87313.90
5.5.350.0160.83214.04
5.5.340.0320.85513.77
5.5.330.0100.84813.60
5.5.320.0160.82113.66
5.5.310.0070.84613.66
5.5.300.0100.86514.09
5.5.290.0100.81513.91
5.5.280.0100.87113.90
5.5.270.0190.84514.08
5.5.260.0070.83513.73
5.5.250.0130.84213.93
5.5.240.0160.86314.11
5.5.230.0130.81813.89
5.5.220.0170.82713.99
5.5.210.0100.80713.93
5.5.200.0160.90013.73
5.5.190.0160.83313.77
5.5.180.0130.83113.93
5.5.170.0190.81817.15
5.5.160.0100.80713.72
5.5.150.0130.82213.64
5.5.140.0220.81513.95
5.5.130.0230.77713.81
5.5.120.0200.86214.09
5.5.110.0190.80613.91
5.5.100.0160.82713.94
5.5.90.0310.83413.96
5.5.80.0230.81413.81
5.5.70.0100.82513.84
5.5.60.0260.84114.10
5.5.50.0230.85813.73
5.5.40.0100.82713.97
5.5.30.0160.82813.81
5.5.20.0260.89713.70
5.5.10.0220.83613.59
5.5.00.0130.84813.70
5.4.450.0160.83113.58
5.4.440.0130.84413.92
5.4.430.0100.81713.81
5.4.420.0160.86413.90
5.4.410.0190.84814.04
5.4.400.0220.94613.77
5.4.390.0100.84713.89
5.4.380.0130.83713.77
5.4.370.0130.82413.52
5.4.360.0030.82413.73
5.4.350.0370.84513.81
5.4.340.0220.83813.69
5.4.330.0130.81613.64
5.4.320.0100.81913.72
5.4.310.0160.81013.68
5.4.300.0160.82213.66
5.4.290.0190.80313.91
5.4.280.0100.83213.99
5.4.270.0260.82713.69
5.4.260.0130.82614.01
5.4.250.0130.84613.68
5.4.240.0160.83613.66
5.4.230.0100.87113.74
5.4.220.0130.82813.73
5.4.210.0100.84414.00
5.4.200.0220.82213.43
5.4.190.0230.84713.69
5.4.180.0320.86813.75
5.4.170.0130.85213.90
5.4.160.0100.81913.67
5.4.150.0170.80113.77
5.4.140.0200.85813.57
5.4.130.0160.84613.76
5.4.120.0070.83713.70
5.4.110.0150.84913.92
5.4.100.0180.84713.80
5.4.90.0130.82013.84
5.4.80.0130.81213.80
5.4.70.0190.85013.81
5.4.60.0160.82413.75
5.4.50.0100.82613.79
5.4.40.0160.80813.78
5.4.30.0160.85913.80
5.4.20.0200.85013.73
5.4.10.0340.80313.71
5.4.00.0190.80613.54
5.3.290.0260.83013.02
5.3.280.0190.85113.24
5.3.270.0160.83113.22
5.3.260.0100.80613.11
5.3.250.0060.82413.14
5.3.240.0000.80012.96
5.3.230.0190.83713.14
5.3.220.0130.84413.05
5.3.210.0100.87012.93
5.3.200.0200.82312.85
5.3.190.0070.79213.00
5.3.180.0130.81513.09
5.3.170.0160.90913.12
5.3.160.0230.79113.23
5.3.150.0230.80312.95
5.3.140.0160.83313.05
5.3.130.0160.79612.98
5.3.120.0130.82913.09
5.3.110.0130.81213.16
5.3.100.0070.82512.97
5.3.90.0130.83513.03
5.3.80.0300.85612.93
5.3.70.0090.83412.95
5.3.60.0250.83113.07
5.3.50.0130.90713.07
5.3.40.0130.87513.07
5.3.30.0280.85513.00
5.3.20.0190.83513.08
5.3.10.0090.82012.88
5.3.00.0290.85112.88
5.2.170.0100.84711.90
5.2.160.0030.88712.00
5.2.150.0250.84012.10
5.2.140.0100.79311.81
5.2.130.0190.87011.88
5.2.120.0190.93111.90
5.2.110.0130.82112.01
5.2.100.0160.82312.05
5.2.90.0100.82211.88
5.2.80.0090.82811.85
5.2.70.0231.11711.82
5.2.60.0100.89611.50
5.2.50.0190.83811.86
5.2.40.0200.78611.97
5.2.30.0130.84911.57
5.2.20.0090.81211.81
5.2.10.0280.79311.69
5.2.00.0060.83911.46
5.1.60.0161.00112.23
5.1.50.0351.04612.00
5.1.40.0170.99812.31
5.1.30.0090.96412.39
5.1.20.0200.94612.16
5.1.10.0160.98212.02
5.1.00.0030.98812.02
5.0.50.0191.05311.05
5.0.40.0320.98411.20
5.0.30.0261.00111.07
5.0.20.0221.10711.08
5.0.10.0100.96810.98
5.0.00.0151.03310.68
4.4.90.0221.0069.48
4.4.80.0101.0209.48
4.4.70.0031.0409.48
4.4.60.0231.0789.48
4.4.50.0181.4029.48
4.4.40.0331.0999.48
4.4.30.0231.0469.48
4.4.20.0101.0439.48
4.4.10.0201.0589.48
4.4.00.0161.0659.48
4.3.110.0231.0189.48
4.3.100.0061.1389.48
4.3.90.0061.0049.48
4.3.80.0101.0079.48
4.3.70.0261.0429.48
4.3.60.0221.0769.48
4.3.50.0131.0399.48
4.3.40.0191.0579.48
4.3.30.0231.0049.48
4.3.20.0061.0259.48
4.3.10.0161.0069.48
4.3.00.0191.0079.48

preferences:
47.79 ms | 401 KiB | 5 Q