3v4l.org

run code in 300+ PHP versions simultaneously
<?php function returnTime(callable $function, int $repeat = 100) { $tests = []; for ($i = 0; $i < $repeat; ++$i) { $startTime = microtime(true); $function(); $endTime = microtime(true); $tests[] = $endTime - $startTime; } // Representing the average return 1000 * array_sum($tests) / $repeat; } $array = array_fill(0, 500000, 1); echo "Duration of array_slice() + key(): ", returnTime(function() use ($array) { $lastKey = key(array_slice($array, -1, 1, true)); }); echo PHP_EOL; echo "Duration of end() + key(): " , returnTime(function() use ($array){ end($array); $lastKey = key($array); }); echo PHP_EOL; echo "Duration of array_key_last(): " , returnTime(function() use ($array){ $lastKey = array_key_last($array); });

Abusive script

This script was stopped while abusing our resources

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.31.1330.83746.88
7.4.21.0620.73446.54
7.4.11.0460.77146.78
7.4.01.1240.78446.97
7.3.150.9850.83346.74
7.3.141.0770.67746.63
7.3.131.0270.77246.80
7.3.121.0300.80746.74
7.3.111.0660.78146.70
7.3.101.3860.85946.86
7.3.91.1490.77146.79
7.3.81.1150.75046.84
7.3.70.9990.70446.04
7.3.61.0720.71746.08
7.3.50.9670.72545.90
7.3.41.0370.69045.82
7.3.31.0220.68846.00
7.3.20.9600.75948.55
7.3.10.4240.65849.28
7.3.00.3220.69649.16
7.2.281.0970.74047.17
7.2.271.0190.75646.88
7.2.261.2640.87947.14
7.2.251.1950.68646.86
7.2.241.0610.74046.99
7.2.231.1120.82046.89
7.2.221.0000.86747.09
7.2.211.1580.75647.12
7.2.201.0020.71246.08
7.2.191.0010.69646.34
7.2.181.0180.65746.11
7.2.171.0380.65646.14
7.2.161.0850.71646.10
7.2.150.7120.75349.38
7.2.140.2640.69549.61
7.2.130.2970.70449.55
7.2.120.3240.65949.57
7.2.110.2880.71749.34
7.2.100.3090.72849.46
7.2.90.3220.69249.55
7.2.80.2990.77349.57
7.2.70.2890.69649.65
7.2.60.2970.64649.64
7.2.50.3230.62349.46
7.2.40.3180.64649.41
7.2.30.3040.67849.52
7.2.20.2940.66249.59
7.2.10.3140.66549.54
7.2.00.2840.73849.46
7.1.331.5460.82546.08
7.1.321.5420.78245.96
7.1.311.6300.80046.23
7.1.300.8970.70446.86
7.1.290.9030.68346.91
7.1.280.9390.74346.74
7.1.270.9710.72347.91
7.1.260.3050.77448.51
7.1.250.2900.72948.43
7.1.240.3740.78749.39
7.1.230.3470.78249.26
7.1.220.3830.82349.39
7.1.210.4250.82449.34
7.1.200.3080.81649.40
7.1.190.3410.84249.46
7.1.180.3400.78449.34
7.1.170.3500.73249.09
7.1.160.3700.76349.09
7.1.150.3540.73149.21
7.1.140.2990.73749.29
7.1.130.2790.79149.28
7.1.120.3130.76649.16
7.1.110.3210.72349.32
7.1.100.3130.74649.32
7.1.90.3570.69849.39
7.1.80.3050.67049.40
7.1.70.2900.73649.42
7.1.60.2780.71149.18
7.1.50.3120.65749.31
7.1.40.2800.71549.23
7.1.30.3140.65249.52
7.1.20.2750.71349.52
7.1.10.2720.74049.33
7.1.00.3200.77949.44

preferences:
29.23 ms | 403 KiB | 5 Q