3v4l.org

run code in 300+ PHP versions simultaneously
<?php define('ARRAY_SIZE', 512); define('RUNS', 1e4); 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 * $eacha; }, $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.0002.50117.09
7.1.60.0102.49119.46
7.1.50.0072.49517.14
7.1.00.0032.49722.19
7.0.200.0132.17816.79
7.0.140.0032.49722.18
7.0.100.0132.48720.02
7.0.90.0002.50020.02
7.0.80.0032.49719.95
7.0.70.0232.47719.99
7.0.60.0072.49319.84
7.0.50.0072.48320.30
7.0.40.0172.46720.11
7.0.30.0072.49320.00
7.0.20.0072.49320.04
7.0.10.0032.47020.07
7.0.00.0072.47720.04
5.6.280.0002.50021.27
5.6.250.0032.49720.82
5.6.240.0002.50020.77
5.6.230.0032.49720.90
5.6.220.0032.49720.82
5.6.210.0072.49320.83
5.6.200.0072.39321.30
5.6.190.0032.44021.19
5.6.180.0072.48021.10
5.6.170.0002.50021.23
5.6.160.0072.48021.07
5.6.150.0132.47321.18
5.6.140.0172.48321.12
5.6.130.0072.46321.20
5.6.120.0032.47721.25
5.6.110.0002.43021.29
5.6.100.0102.47321.23
5.6.90.0032.45321.16
5.6.80.0002.47320.57
5.6.70.0072.46720.59
5.6.60.0032.39720.66
5.6.50.3031.99320.58
5.6.40.0072.45320.54
5.6.30.0072.45720.59
5.6.20.0172.45020.56
5.6.10.0072.46720.53
5.6.00.0102.46320.61
5.5.380.0032.49720.49
5.5.370.0102.43320.57
5.5.360.0202.43320.66
5.5.350.0302.40720.65
5.5.340.0202.39321.02
5.5.330.0232.43721.04
5.5.320.0232.35721.14
5.5.310.0232.44320.85
5.5.300.0132.40720.96
5.5.290.0172.41721.09
5.5.280.0072.31321.00
5.5.270.0202.41720.96
5.5.260.0132.41021.10
5.5.250.0232.43020.82
5.5.240.0172.39320.35
5.5.230.0132.40720.34
5.5.220.0302.18720.51
5.5.210.0202.42320.42
5.5.200.0102.43720.30
5.5.190.0232.46320.49
5.5.180.0132.41720.47
5.5.160.0232.42320.44
5.5.150.0502.36720.44
5.5.140.0272.36720.39
5.5.130.0202.42720.34
5.5.120.0272.40320.44
5.5.110.0132.46020.21
5.5.100.0102.42020.19
5.5.90.0072.43720.18
5.5.80.0072.39720.34
5.5.70.0232.44720.33
5.5.60.0172.41020.30
5.5.50.0032.46020.17
5.5.40.0172.43720.16
5.5.30.0102.42720.24
5.5.20.0232.44320.29
5.5.10.0272.36020.21
5.5.00.0272.38020.26
5.4.450.0302.42019.54
5.4.440.0202.41019.67
5.4.430.0332.39719.38
5.4.420.0272.41319.67
5.4.410.0072.38319.36
5.4.400.0232.45319.21
5.4.390.0202.42319.00
5.4.380.0102.40719.18
5.4.370.0202.43319.20
5.4.360.0132.38019.20
5.4.350.0202.43019.12
5.4.340.0102.37719.39
5.4.320.0272.38719.20
5.4.310.0102.41319.23
5.4.300.0202.40019.00
5.4.290.0332.39319.17
5.4.280.0172.37319.34
5.4.270.0132.47319.19
5.4.260.0102.42719.04
5.4.250.0102.41319.09
5.4.240.0202.39019.09
5.4.230.0302.39719.18
5.4.220.0332.39319.18
5.4.210.0072.43719.05
5.4.200.0202.44019.20
5.4.190.0332.42019.24
5.4.180.0132.41319.20
5.4.170.0302.38018.99
5.4.160.0172.44719.16
5.4.150.0202.39719.16
5.4.140.0202.40016.50
5.4.130.0272.25316.45
5.4.120.0102.46016.46
5.4.110.0172.40316.42
5.4.100.0202.41716.67
5.4.90.0172.43016.48
5.4.80.0272.39716.62
5.4.70.0002.45316.47
5.4.60.0132.42316.60
5.4.50.0232.40016.41
5.4.40.0232.40316.68
5.4.30.0102.40316.41
5.4.20.0132.44016.61
5.4.10.0232.40016.60
5.4.00.0072.43716.07
5.3.290.0172.46014.63
5.3.280.0102.46314.63
5.3.270.0202.40314.61
5.3.260.0102.45314.62
5.3.250.0172.44314.74
5.3.240.0132.30314.58
5.3.230.0302.26714.62
5.3.220.0202.42014.53
5.3.210.0202.42014.70
5.3.200.0202.40014.52
5.3.190.0232.35014.43
5.3.180.0172.39314.54
5.3.170.0032.43714.49
5.3.160.0202.40314.43
5.3.150.0432.42714.60
5.3.140.0272.41714.69
5.3.130.0202.40714.51
5.3.120.0202.41714.55
5.3.110.0232.38314.54
5.3.100.0272.37714.05
5.3.90.0332.35713.88
5.3.80.0102.42713.95
5.3.70.0172.37713.93
5.3.60.0232.25313.90
5.3.50.0272.38013.87
5.3.40.0102.37713.88
5.3.30.0232.38713.97
5.3.20.0132.38713.62
5.3.10.0172.37313.55
5.3.00.0272.41013.59
5.2.170.0070.05011.37
5.2.160.0000.06311.37
5.2.150.0030.06311.37
5.2.140.0100.04011.37
5.2.130.0030.05311.37
5.2.120.0000.05311.37
5.2.110.0030.02711.37
5.2.100.0000.03011.37
5.2.90.0100.02311.37
5.2.80.0000.04011.37
5.2.70.0000.03011.37
5.2.60.0000.03011.37
5.2.50.0000.03011.37
5.2.40.0030.02711.37
5.2.30.0000.03011.37
5.2.20.0100.02011.37
5.2.10.0070.02311.37
5.2.00.0030.02311.37
5.1.60.0100.01311.37
5.1.50.0070.02011.37
5.1.40.0070.02711.37
5.1.30.0070.02011.37
5.1.20.0100.02011.39
5.1.10.0070.03711.42
5.1.00.0030.05311.43
5.0.50.0030.04011.45
5.0.40.0030.03711.46
5.0.30.0070.03011.49
5.0.20.0100.03011.51
5.0.10.0070.03711.52
5.0.00.0070.06711.53
4.4.90.0000.01711.37
4.4.80.0030.01311.37
4.4.70.0000.01711.37
4.4.60.0000.01711.37
4.4.50.0030.01311.37
4.4.40.0000.02011.37
4.4.30.0000.01711.37
4.4.20.0000.03311.41
4.4.10.0070.01311.45
4.4.00.0030.04311.46
4.3.110.0000.03311.47
4.3.100.0030.03311.51
4.3.90.0030.02711.52
4.3.80.0000.03011.54
4.3.70.0030.03011.55
4.3.60.0030.02311.55
4.3.50.0000.01711.55
4.3.40.0030.03011.59
4.3.30.0030.01711.59
4.3.20.0000.03011.59
4.3.10.0030.03011.60
4.3.00.0030.01711.61

preferences:
36.56 ms | 400 KiB | 5 Q