3v4l.org

run code in 300+ PHP versions simultaneously
<?php $funcs = [ function ($array) { end($array); $key = key($array); reset($array); return $key; }, function ($array) { return count($array) - 1; }, function ($array) { return key(array_slice($array,-1,1,true)); }, function ($array) { $keys = array_keys($array); return end($keys); } ]; $test = ['a', 'b', 'c', 'd', 'e']; foreach ($funcs as $f) { $results = []; for ($i = 0; $i < 10000; $i++) { $start_time = microtime(TRUE); $f($test); $end_time = microtime(TRUE); $results[] = $end_time - $start_time; } echo sprintf('%f.4', array_sum($results) / count($results)) . 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)
7.2.60.0000.02316.68
7.2.00.0000.02119.32
7.1.100.0070.01718.29
7.1.70.1330.05015.79
7.1.60.1830.04033.80
7.1.50.0430.04333.49
7.1.40.1770.03033.09
7.1.30.1730.02333.15
7.1.20.0130.05333.25
7.1.10.1730.04715.17
7.1.00.1830.04015.15
7.0.200.1630.04015.06
7.0.190.0100.05015.45
7.0.180.0100.04314.79
7.0.170.0070.05014.77
7.0.160.2130.04714.73
7.0.150.0030.04714.90
7.0.140.1870.04014.80
7.0.130.0000.05015.01
7.0.120.0000.05015.26
7.0.110.0030.04714.81
7.0.100.2070.05014.80
7.0.90.0170.04015.09
7.0.80.0130.03314.96
7.0.70.0170.03314.83
7.0.60.0100.04014.83
7.0.50.0030.04314.83
7.0.40.0130.03314.80
7.0.30.0370.03015.22
7.0.20.0100.04315.01
7.0.10.0030.04714.95
7.0.00.2370.02714.94

preferences:
34.77 ms | 401 KiB | 5 Q