3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('ARRAY_SIZE', 512); define('RUNS', 10000); function benchmark($function, $desc) { $total_time = 0; for($i = 0; $i < RUNS; $i++) { $total_time += $function(); } echo sprintf('%dx %s took %.5f seconds' . PHP_EOL, RUNS, $desc, $total_time); } benchmark(function() { $r = range(0, ARRAY_SIZE); $start = microtime(true); foreach ($r as $k => $v) { for($i = 0; $i++ < $v;) { $r[$k] = $v * $v; }} return microtime(true) - $start; }, 'foreach'); benchmark(function() { $r = range(0, ARRAY_SIZE); $start = microtime(true); $r = array_map(function($each) { return $each * $each; }, $r); return microtime(true) - $start; }, 'array_map');

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.1.70.0172.45017.04
7.1.60.0032.49819.46
7.1.50.0072.49517.03
7.1.00.0102.49022.45
7.0.200.0102.48916.50
7.0.140.0002.50022.00
7.0.60.0032.49719.92
7.0.50.0072.49317.85
7.0.40.0102.49020.00
7.0.30.0232.47719.94
7.0.20.0332.46719.97
7.0.10.0132.48719.80
7.0.00.0032.49719.80
5.6.280.0102.49021.23
5.6.210.0102.49020.85
5.6.200.0072.49318.25
5.6.190.0032.49720.52
5.6.180.0402.46020.36
5.6.170.0332.46720.60
5.6.160.0102.49020.50
5.6.150.0132.48718.34
5.6.140.0032.49718.34
5.6.130.0072.49318.33
5.6.120.0072.49321.14
5.6.110.0032.49721.14
5.6.100.0032.49721.17
5.6.90.0072.49321.22
5.6.80.0032.47320.54
5.5.350.0232.42320.62
5.5.340.0302.37321.02
5.5.330.0202.41321.05
5.5.320.0332.42721.12
5.5.310.0202.39021.09
5.5.300.0332.41021.02
5.5.290.0272.42321.09
5.5.280.0102.45321.02
5.5.270.0202.41721.09
5.5.260.0102.45021.09
5.5.250.0202.36720.90
5.5.240.0172.45320.40
5.4.450.0202.45319.54
5.4.440.0232.35719.58
5.4.430.0302.39319.69
5.4.420.0202.45019.53
5.4.410.0102.41319.38
5.4.400.0302.41719.26
5.4.390.0272.37319.01
5.4.380.0232.39319.18
5.4.370.0132.45319.17
5.4.360.0272.42019.37
5.4.350.0102.43719.22
5.4.340.0332.38319.18
5.4.320.0132.43319.18
5.4.310.0232.43319.21
5.4.300.0202.42319.22
5.4.290.0232.42719.00
5.4.280.0302.42019.25
5.4.270.0132.42319.19
5.4.260.0302.41719.33
5.4.250.0232.45319.33
5.4.240.0172.37719.05
5.4.230.0332.36019.00
5.4.220.0302.37719.03
5.4.210.0272.42719.19
5.4.200.0272.40019.20
5.4.190.0232.39719.21
5.4.180.0202.39319.35
5.4.170.0102.43019.05
5.4.160.0172.41719.16
5.4.150.0232.44019.23
5.4.140.0102.44016.72
5.4.130.0032.47716.49
5.4.120.0072.41016.40
5.4.110.0202.45016.48
5.4.100.0302.42716.63
5.4.90.0132.43316.67
5.4.80.0172.38316.62
5.4.70.0002.44316.65
5.4.60.0172.37316.64
5.4.50.0372.37016.57
5.4.40.0232.37716.42
5.4.30.0132.43316.66
5.4.20.0332.42316.60
5.4.10.0332.36716.64
5.4.00.0472.08715.85
5.3.290.0332.33014.67
5.3.280.0102.44014.57
5.3.270.0302.40714.63
5.3.260.0332.38014.63
5.3.250.0102.44714.61
5.3.240.0372.38014.61
5.3.230.0202.43314.43
5.3.220.0202.41714.58
5.3.210.0302.43014.57
5.3.200.0272.40314.49
5.3.190.0232.40314.61
5.3.180.0232.39714.56
5.3.170.0172.43714.60
5.3.160.0272.42314.56
5.3.150.0372.34014.59
5.3.140.0302.35014.55
5.3.130.0072.42014.55
5.3.120.0272.40314.52
5.3.110.0272.32714.44
5.3.100.0232.40713.96
5.3.90.0272.40313.98
5.3.80.0202.44313.81
5.3.70.0232.41313.91
5.3.60.0172.38013.92
5.3.50.0372.38713.87
5.3.40.0232.38713.88
5.3.30.0172.41313.84
5.3.20.0272.45313.67
5.3.10.0272.42013.44
5.3.00.0102.44313.70
5.2.170.0430.04011.81
5.2.160.0370.05311.77
5.2.150.0500.04711.84
5.2.140.2600.03311.88
5.2.130.2830.03311.87
5.2.120.0500.04311.88
5.2.110.0370.02711.88
5.2.100.0330.03011.84
5.2.90.0300.03011.85
5.2.80.0370.02311.78
5.2.70.0170.03311.85
5.2.60.0400.05011.83
5.2.50.0300.03711.87
5.2.40.0330.02711.82
5.2.30.0400.04711.82
5.2.20.0330.05711.85
5.2.10.0300.05311.80
5.2.00.0070.04711.82
5.1.60.0300.04311.88
5.1.50.0400.03711.88
5.1.40.0200.05013.81
5.1.30.0030.02313.78
5.1.20.0070.05713.88
5.1.10.0300.04313.86
5.1.00.0330.04313.88
5.0.50.0270.04313.77
5.0.40.0200.02713.88
5.0.30.0130.02713.88
5.0.20.0230.02313.88
5.0.10.0170.02313.83
5.0.00.0000.03713.88
4.4.90.0000.03713.84
4.4.80.0000.01713.88
4.4.70.0000.02713.80
4.4.60.0000.02313.84
4.4.50.0130.01313.88
4.4.40.0000.02313.84
4.4.30.0030.02713.88
4.4.20.0070.03313.84
4.4.10.0070.01713.87
4.4.00.0100.04013.91
4.3.110.0030.01713.87
4.3.100.0170.01313.88
4.3.90.0070.01713.91
4.3.80.0030.05713.90
4.3.70.0030.02313.85
4.3.60.0200.01713.91
4.3.50.0970.01713.88
4.3.40.1270.02013.88
4.3.30.0670.02313.91
4.3.20.1030.01713.91
4.3.10.0870.02013.91
4.3.00.0100.03313.91

preferences:
37.19 ms | 401 KiB | 5 Q