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.3.10.0070.23216.38
7.3.00.0100.22916.50
7.2.130.0130.22216.91
7.2.120.0120.22316.66
7.2.110.0100.22416.78
7.2.100.0210.22616.73
7.2.90.0120.22616.88
7.2.80.0080.23016.78
7.2.70.0100.23416.68
7.2.60.0060.23616.73
7.2.50.0080.23316.79
7.2.40.0120.24216.80
7.2.30.0120.24316.69
7.2.20.0150.23416.68
7.2.10.0120.24116.83
7.2.00.0070.24116.86
7.1.250.0050.22815.69
7.1.240.0200.23215.66
7.1.230.0170.24315.61
7.1.220.0200.22915.94
7.1.210.0160.23115.94
7.1.200.0130.23715.89
7.1.190.0100.24415.70
7.1.180.0200.22715.74
7.1.170.0200.23615.77
7.1.160.0190.22715.63
7.1.150.0170.23515.32
7.1.140.0200.22515.52
7.1.130.0170.23315.46
7.1.120.0390.23216.63
7.1.110.0460.21116.45
7.1.100.0740.23316.04
7.1.90.0750.23116.44
7.1.80.0370.22116.26
7.1.70.0490.21715.81
7.1.60.0370.22124.87
7.1.50.0380.23124.73
7.1.40.0440.23324.36
7.1.30.0380.23024.56
7.1.20.0450.22324.42
7.1.10.0430.22815.65
7.1.00.0380.21815.76
7.0.330.0100.24315.37
7.0.320.0200.24114.94
7.0.310.0170.24115.40
7.0.300.0200.23215.29
7.0.290.0070.23714.92
7.0.280.0130.22914.91
7.0.270.0100.23815.50
7.0.260.0100.24315.37
7.0.250.0380.22615.81
7.0.240.0510.27415.82
7.0.230.0390.26716.06
7.0.220.0720.25215.72
7.0.210.0330.25815.43
7.0.200.0620.22215.59
7.0.190.0690.23915.52
7.0.180.0300.24715.33
7.0.170.0420.23615.36
7.0.160.0540.22215.18
7.0.150.0430.22015.27
7.0.140.0450.23815.33
7.0.130.0500.21215.27
7.0.120.0350.22815.56
7.0.110.0350.22315.23
7.0.100.0520.22215.37
7.0.90.0780.22715.39
7.0.80.0420.21715.33
7.0.70.0500.22515.14
7.0.60.0130.22115.31
7.0.50.0620.27615.26
7.0.40.0580.27014.29
7.0.30.0210.24114.37
7.0.20.0390.23514.39
7.0.10.0100.22314.42
7.0.00.0400.22114.30
5.6.380.0100.55317.30

preferences:
27.62 ms | 403 KiB | 5 Q