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 * $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.0102.43617.02
7.1.60.0002.50119.46
7.1.50.0072.49516.81
7.1.00.0032.49722.19
7.0.200.0032.49816.77
7.0.140.0072.49322.08
7.0.60.0032.49719.95
7.0.50.0102.49017.94
7.0.40.0032.49719.89
7.0.30.0272.47319.89
7.0.20.0272.47320.00
7.0.10.0002.50019.91
7.0.00.0102.49019.81
5.6.280.0002.50020.97
5.6.210.0072.49320.69
5.6.200.0132.48718.25
5.6.190.0102.49020.52
5.6.180.0202.48020.61
5.6.170.0172.48320.55
5.6.160.0072.49320.54
5.6.150.0032.49718.31
5.6.140.0132.48718.34
5.6.130.0102.49018.27
5.6.120.0032.49721.24
5.6.110.0132.48721.30
5.6.100.0032.49721.30
5.6.90.0172.48321.28
5.6.80.0202.48020.56
5.5.350.0432.38020.62
5.5.340.0272.43721.12
5.5.330.0232.43721.07
5.5.320.0272.44321.02
5.5.310.0432.29721.07
5.5.300.0132.44021.04
5.5.290.0232.31021.09
5.5.280.0271.99720.88
5.5.270.0231.91320.99
5.5.260.0432.34020.96
5.5.250.0332.38020.83
5.5.240.0202.42020.35
5.4.450.0132.44719.39
5.4.440.0231.95019.34
5.4.430.0102.00719.51
5.4.420.0401.95319.54
5.4.410.0232.42019.39
5.4.400.0302.43719.10
5.4.390.0272.42719.22
5.4.380.0172.41319.37
5.4.370.0202.40019.04
5.4.360.0102.43019.21
5.4.350.0132.44319.34
5.4.340.0202.36719.25
5.4.320.0172.21019.21
5.4.310.0231.82319.37
5.4.300.0171.89019.34
5.4.290.0131.80019.21
5.4.280.0131.92719.18
5.4.270.0301.94319.36
5.4.260.0131.74019.04
5.4.250.0132.16019.18
5.4.240.0202.36019.21
5.4.230.0172.44019.09
5.4.220.0202.41319.20
5.4.210.0172.39719.20
5.4.200.0102.43718.99
5.4.190.0202.41719.05
5.4.180.0102.41719.13
5.4.170.0202.39719.36
5.4.160.0132.45019.35
5.4.150.0302.38019.20
5.4.140.0202.41016.61
5.4.130.0302.40716.46
5.4.120.0132.40716.66
5.4.110.0172.43316.48
5.4.100.0372.41016.67
5.4.90.0272.40016.49
5.4.80.0102.39716.43
5.4.70.0272.34316.48
5.4.60.0072.45716.60
5.4.50.0172.44716.55
5.4.40.0272.44716.47
5.4.30.0132.43316.66
5.4.20.0172.38016.66
5.4.10.0172.36016.56
5.4.00.0272.41716.00
5.3.290.0272.11314.68
5.3.280.0102.42714.63
5.3.270.0232.41314.58
5.3.260.0102.44014.57
5.3.250.0172.34014.57
5.3.240.0172.41314.61
5.3.230.0272.40314.52
5.3.220.0302.41314.70
5.3.210.0332.37014.57
5.3.200.0202.39314.57
5.3.190.0232.35714.43
5.3.180.0332.40014.54
5.3.170.0202.35714.53
5.3.160.0172.45314.57
5.3.150.0232.39014.56
5.3.140.0102.45014.57
5.3.130.0232.41014.52
5.3.120.0132.43314.52
5.3.110.0202.42714.56
5.3.100.0072.40014.18
5.3.90.0232.41714.03
5.3.80.0332.40713.92
5.3.70.0132.40713.93
5.3.60.0132.36313.95
5.3.50.0172.44313.74
5.3.40.0202.41713.89
5.3.30.0372.44013.71
5.3.20.0132.43013.61
5.3.10.0132.33013.63
5.3.00.0302.42713.59
5.2.170.0330.05011.84
5.2.160.0300.04311.80
5.2.150.0370.05711.84
5.2.140.2800.03311.86
5.2.130.2600.03011.88
5.2.120.0470.05311.88
5.2.110.0470.04311.88
5.2.100.0530.02311.84
5.2.90.0470.03011.85
5.2.80.0300.03711.84
5.2.70.0330.02311.85
5.2.60.0500.06011.87
5.2.50.0400.05311.87
5.2.40.0300.05311.82
5.2.30.0400.04311.85
5.2.20.0370.05011.85
5.2.10.0300.04711.82
5.2.00.0030.03011.82
5.1.60.0330.04711.88
5.1.50.0270.02011.88
5.1.40.0200.02713.81
5.1.30.0030.04013.86
5.1.20.0070.05013.88
5.1.10.0400.03013.86
5.1.00.0370.03313.88
5.0.50.0230.04013.86
5.0.40.0130.02013.88
5.0.30.0170.03313.88
5.0.20.0170.03313.88
5.0.10.0070.02013.83
5.0.00.0030.03013.88
4.4.90.0070.02313.84
4.4.80.0000.01313.88
4.4.70.0000.02313.80
4.4.60.0030.01013.84
4.4.50.0030.03013.91
4.4.40.0000.02713.84
4.4.30.0070.03013.88
4.4.20.0100.03313.84
4.4.10.0100.03013.91
4.4.00.0100.05313.91
4.3.110.0070.03713.88
4.3.100.0130.01713.88
4.3.90.0130.02713.91
4.3.80.0100.03713.90
4.3.70.0130.01713.91
4.3.60.0170.03013.91
4.3.50.1200.01313.88
4.3.40.1300.02313.88
4.3.30.0730.01313.91
4.3.20.0870.02313.91
4.3.10.0770.01713.91
4.3.00.0030.01713.91

preferences:
36.01 ms | 401 KiB | 5 Q