3v4l.org

run code in 300+ PHP versions simultaneously
<?php $memoize = function ($fn, $cacheKeyFn = null, $limit = null) { $cache = array(); return function () use ($fn, $cacheKeyFn, $limit, & $cache) { $args = func_get_args(); if ($cacheKeyFn) { $key = call_user_func_array($cacheKeyFn, $args); } else { $key = reset($args); } if (isset($cache[$key])) { return $cache[$key]; } $result = call_user_func_array($fn, $args); if ($limit !== null && count($cache) === $limit) { array_shift($cache); } $cache[$key] = $result; return $result; }; }; $numCalls = 0; $memoFib = $memoize( function ($n) use (& $memoFib, & $numCalls) { $numCalls++; if ($n === 1 || $n === 2) return 1; return $memoFib($n - 1) + $memoFib($n - 2); } } ); foreach (range(0,1) as $i) { echo $memoFib($i) . 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)
5.4.320.0170.03719.00
5.4.310.0270.03319.20
5.4.300.0130.03719.16
5.4.290.0270.02318.99
5.4.280.0130.03719.24
5.4.270.0170.03719.23
5.4.260.0130.03719.13
5.4.250.0070.04318.98
5.4.240.0170.03719.22
5.4.230.0200.03018.84
5.4.220.0200.04018.87
5.4.210.0130.03719.14
5.4.200.0100.04019.21
5.4.190.0130.05319.15
5.4.180.0170.03318.98
5.4.170.0070.04319.09
5.4.160.0200.03319.22
5.4.150.0200.04318.96
5.4.140.0200.07316.44
5.4.130.0130.05316.56
5.4.120.0200.07016.40
5.4.110.0230.04316.32
5.4.100.0170.06716.59
5.4.90.0230.07016.59
5.4.80.0130.05016.50
5.4.70.0200.03316.49
5.4.60.0270.05016.51
5.4.50.0270.06316.43
5.4.40.0200.03316.38
5.4.30.0330.06016.42
5.4.20.0230.04316.42
5.4.10.0200.06316.16
5.4.00.0230.05016.12
5.3.290.0200.03314.73
5.3.280.0200.03014.66
5.3.270.0100.04014.53
5.3.260.0170.04314.70
5.3.250.0270.04014.52
5.3.240.0200.05714.66
5.3.230.0130.07314.60
5.3.220.0230.03314.59
5.3.210.0130.05014.50
5.3.200.0200.06714.51
5.3.190.0200.04314.57
5.3.180.0170.06014.50
5.3.170.0230.06314.59
5.3.160.0230.06714.61
5.3.150.0200.06314.66
5.3.140.0230.06714.58
5.3.130.0270.06714.80
5.3.120.0270.07014.54
5.3.110.0270.06014.57
5.3.100.0270.06314.14
5.3.90.0200.04014.01
5.3.80.0170.05713.94
5.3.70.0230.03714.27
5.3.60.0200.03314.10
5.3.50.0100.04313.87
5.3.40.0200.07713.88
5.3.30.0130.04313.84
5.3.20.0200.05013.66
5.3.10.0270.03313.68
5.3.00.0200.05713.57
5.2.170.0130.06012.43
5.2.160.0230.04712.43
5.2.150.0170.04712.43
5.2.140.0230.05712.43
5.2.130.0170.04312.43
5.2.120.0130.06012.43
5.2.110.0200.05712.43
5.2.100.0200.04012.43
5.2.90.0170.05712.43
5.2.80.0170.06312.43
5.2.70.0130.04012.43
5.2.60.0230.03712.43
5.2.50.0270.05012.43
5.2.40.0270.03312.43
5.2.30.0230.03712.43
5.2.20.0130.06012.43
5.2.10.0170.05712.43
5.2.00.0200.06712.43
5.1.60.0170.04012.43
5.1.50.0170.03012.43
5.1.40.0170.05012.43
5.1.30.0170.03712.43
5.1.20.0130.03712.43
5.1.10.0230.02012.43
5.1.00.0130.02712.43
5.0.50.0070.02012.43
5.0.40.0030.02012.43
5.0.30.0200.03312.43
5.0.20.0100.04012.43
5.0.10.0070.03712.43
5.0.00.0070.05012.43
4.4.90.0070.03012.43
4.4.80.0130.03012.43
4.4.70.0100.02012.43
4.4.60.0130.03312.43
4.4.50.0030.04012.43
4.4.40.0030.04712.43
4.4.30.0070.02712.43
4.4.20.0070.02712.43
4.4.10.0030.04012.43
4.4.00.0070.02312.43
4.3.110.0000.02012.43
4.3.100.0070.02712.43
4.3.90.0100.01712.43
4.3.80.0100.05012.43
4.3.70.0070.03012.43
4.3.60.0070.02012.43
4.3.50.0070.03012.43
4.3.40.0030.03712.43
4.3.30.0030.02012.43
4.3.20.0030.03312.43
4.3.10.0100.03312.43
4.3.00.0000.03712.43

preferences:
140.19 ms | 1398 KiB | 7 Q