3v4l.org

run code in 300+ PHP versions simultaneously
<?php const TESTS_TO_RUN = 10; const NUMBERS_TO_SUM = 100000; function displayTabularData($itemList) { // Header $testAmounts = reset(reset($itemList)); printf("%11s", ' '); foreach($testAmounts as $key => $value) printf("[%10s]", $key); echo PHP_EOL; // Info foreach($itemList as $item) { $results = array_shift($item); $name = array_shift($item); printf("[%10s]", $name); foreach ($results as $key => $value) { printf("%.8f, ", $value); } echo PHP_EOL; } } function getRunningTime(callable $callback, $size) { $ts = microtime(); call_user_func($callback, $size); $time = microtime() - $ts; return $time; } function benchmarkCallback(callable $callback, $tests = TESTS_TO_RUN, $step = NUMBERS_TO_SUM) { $collection = []; for($size = $step; $size <= $tests * $step; $size += $step) { $collection[$size] = getRunningTime($callback, $size); } return $collection; } $imperative = function ($size) { for ($sum = 0, $i = 1; $i <= $size; $sum += $i, $i++); }; $functional = function ($size) { array_sum(range(1, $size)); }; displayTabularData([ [benchmarkCallback($imperative), 'Imperative'], [benchmarkCallback($functional), 'Functional'] ]);

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.00.0930.20245.30
7.3.120.0790.19945.40
7.3.110.1020.21145.09
7.3.100.0610.13145.09
7.3.90.0640.14145.26
7.3.80.0760.16345.48
7.3.70.0530.14245.39
7.3.60.0660.17945.24
7.3.50.0770.14045.32
7.3.40.0640.14145.18
7.3.30.0760.16645.27
7.3.20.0590.17248.48
7.3.10.0230.13048.34
7.3.00.0360.17748.57
7.2.250.0860.22245.58
7.2.240.0930.24345.64
7.2.230.0940.21445.34
7.2.220.0600.16745.43
7.2.210.0670.14745.22
7.2.200.0760.21245.47
7.2.190.0700.16345.51
7.2.180.0600.14045.25
7.2.170.0590.16845.53
7.2.00.0130.15651.48
7.1.330.0200.32447.62
7.1.320.0300.30847.73
7.1.310.0170.31747.74
7.1.300.0130.32247.75
7.1.290.0270.31347.64
7.1.280.0680.29947.94
7.1.270.0300.31547.73
7.1.260.0200.32047.79
7.1.70.4040.15649.19
7.1.60.0330.14049.44
7.1.50.0810.20949.29
7.1.00.0300.24354.34
7.0.200.9610.16647.23
7.0.111.6300.20750.46
7.0.101.3470.15350.39
7.0.92.3370.16338.23
7.0.82.3600.14038.30
7.0.72.3130.18747.15
7.0.62.3270.17341.36
7.0.52.3030.19741.07
7.0.42.3200.18039.69
7.0.32.3130.18737.98
7.0.22.3470.15340.73
7.0.12.3100.17740.75
7.0.02.2200.23043.92
5.6.280.0170.45385.53
5.6.260.0530.35084.20
5.6.250.0400.36384.20
5.6.240.0500.50384.27
5.6.230.0470.42384.23
5.6.220.0430.41384.39
5.6.210.0670.40084.13
5.6.200.0430.43784.20
5.6.190.0530.39084.20
5.6.180.0670.40084.43
5.6.170.0570.34084.12
5.6.160.0370.34784.27
5.6.150.0570.41084.13
5.6.140.0430.31784.03
5.6.130.0470.39784.21
5.6.120.0630.36084.13
5.6.110.0570.38084.21
5.6.100.0430.43384.19
5.6.90.0530.42384.16
5.6.80.0630.40783.52
5.6.70.0670.39083.53
5.6.60.0530.43383.65
5.6.50.0470.38783.58
5.6.40.0270.34383.48
5.6.30.0530.45783.48
5.6.20.0600.40783.54
5.6.10.0500.44783.58
5.6.00.0470.36083.50
5.5.380.0630.46384.14
5.5.370.0530.39383.98
5.5.360.0570.39784.07
5.5.350.0500.40384.02
5.5.340.0700.40084.27
5.5.330.0570.43384.56
5.5.320.0670.42384.55
5.5.310.0500.43384.59
5.5.300.0770.40384.35
5.5.290.1070.33084.41
5.5.280.0470.40084.47
5.5.270.0530.35084.27
5.5.260.0530.37384.43
5.5.250.0600.39084.37
5.5.240.0670.39383.91
5.5.230.0430.45783.65
5.5.220.0530.35383.64
5.5.210.0530.43783.73
5.5.200.0470.42383.96
5.5.190.0570.41783.90
5.5.180.0400.41783.94
5.5.160.0500.40083.79
5.5.150.0330.40083.82
5.5.140.0370.43383.82
5.5.130.0370.35783.89
5.5.120.0600.40383.90
5.5.110.0430.43783.76
5.5.100.0470.45783.81
5.5.90.0700.39083.62
5.5.80.0430.43083.82
5.5.70.0270.42384.79
5.5.60.0500.41383.81
5.5.50.0230.35784.65
5.5.40.0570.41083.56
5.5.30.0470.44083.61
5.5.20.0600.38083.80
5.5.10.0800.40083.73
5.5.00.0600.35383.60
5.4.450.0370.37782.88
5.4.440.0470.41382.94
5.4.430.0500.37382.86
5.4.420.0530.42782.95
5.4.410.0600.35082.70
5.4.400.0470.48782.82
5.4.390.0500.41082.63
5.4.380.0500.39782.45
5.4.370.0500.43082.48
5.4.360.0530.40082.61
5.4.350.0370.41782.66
5.4.340.0570.42082.51
5.4.320.0570.40782.56
5.4.310.0500.40082.91
5.4.300.0630.32782.66
5.4.290.0500.40382.56
5.4.280.0400.41082.50
5.4.270.0470.40082.58
5.4.260.0270.41783.36
5.4.250.0100.40383.58
5.4.240.0730.32782.65
5.4.230.0400.41082.50
5.4.220.0430.43382.52
5.4.210.0470.42082.63
5.4.200.0570.40382.49
5.4.190.0730.39082.62
5.4.180.0670.39382.58
5.4.170.0670.38782.63
5.4.160.0470.42782.58
5.4.150.0670.40382.49
5.4.140.0500.40780.04
5.4.130.0630.35079.83
5.4.120.0670.41379.96
5.4.110.0400.40080.04
5.4.100.0570.38380.10
5.4.90.0570.39379.94
5.4.80.0670.35080.05
5.4.70.0400.34380.07
5.4.60.0600.38080.07
5.4.50.0500.42080.01
5.4.40.0430.34379.95
5.4.30.0470.39780.06
5.4.20.0400.46080.07
5.4.10.0370.38780.07
5.4.00.0530.42079.33
5.3.290.0030.07314.67
5.3.280.0070.07314.73
5.3.270.0200.05714.67
5.3.260.0030.07714.76
5.3.250.0000.07714.63
5.3.240.0130.06014.69
5.3.230.0100.07014.59
5.3.220.0030.07714.61
5.3.210.0000.09014.60
5.3.200.0000.08014.71
5.3.190.0100.07314.58
5.3.180.0070.07014.79
5.3.170.0130.07314.80
5.3.160.0100.07314.69
5.3.150.0070.07714.43
5.3.140.0070.07014.59
5.3.130.0030.07714.79
5.3.120.0070.07314.70
5.3.110.0030.08314.55
5.3.100.0070.05714.18
5.3.90.0070.07014.16
5.3.80.0030.07314.26
5.3.70.0100.05714.13
5.3.60.0000.08314.16
5.3.50.0070.07313.82
5.3.40.0070.06713.97
5.3.30.0000.08013.91
5.3.20.0070.07013.93
5.3.10.0100.06713.64
5.3.00.0070.07313.64
5.2.170.0070.05712.04
5.2.160.0000.06312.04
5.2.150.0130.02712.04
5.2.140.0070.06012.04
5.2.130.0070.06312.04
5.2.120.0000.04312.04
5.2.110.0030.06712.04
5.2.100.0000.04312.04
5.2.90.0100.04312.04
5.2.80.0170.05012.04
5.2.70.0070.03312.04
5.2.60.0030.05712.04
5.2.50.0070.06312.04
5.2.40.0100.03712.04
5.2.30.0030.06012.04
5.2.20.0000.07012.04
5.2.10.0100.03312.04
5.2.00.0000.03712.04
5.1.60.0070.05012.04
5.1.50.0030.05012.04
5.1.40.0070.05312.04
5.1.30.0070.03712.04
5.1.20.0070.05312.04
5.1.10.0000.06012.04
5.1.00.0070.05312.04
5.0.50.0100.04012.04
5.0.40.0070.04312.04
5.0.30.0070.06712.04
5.0.20.0030.04012.04
5.0.10.0130.03712.04
5.0.00.0000.07012.04
4.4.90.0030.03312.04
4.4.80.0030.03712.04
4.4.70.0100.01312.04
4.4.60.0030.01312.04
4.4.50.0000.03712.04
4.4.40.0030.02312.04
4.4.30.0000.03712.04
4.4.20.0030.03312.04
4.4.10.0000.03312.04
4.4.00.0000.05312.04
4.3.110.0030.03712.04
4.3.100.0000.03312.04
4.3.90.0030.02012.04
4.3.80.0030.04312.04
4.3.70.0030.03312.04
4.3.60.0030.03312.04
4.3.50.0000.03712.04
4.3.40.0000.04012.04
4.3.30.0000.03712.04
4.3.20.0000.03712.04
4.3.10.0030.02712.04
4.3.00.0100.01012.04

preferences:
59.44 ms | 1656 KiB | 5 Q