3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { public function __construct() { } public static function create() { return new self(); } public function doStuff() { } public static function doStaticStuff() { } } $named = function () { Example::create()->doStuff(); }; $static = function () { Example::doStaticStuff(); }; $test = function ($count) use ($named, $static) { $loop = function ($count, $callable) { $time_start = microtime(true) * 1000; $memory_start = memory_get_usage(true); for ($i = 0; $i < $count; $i++) { $callable(); } $time_end = microtime(true) * 1000; $memory_end = memory_get_usage(true); return [ $time_end - $time_start, $memory_end - $memory_start, ]; }; $static_delta = $loop($count, $static); $named_delta = $loop($count, $named); echo 'After ' . number_format($count) . " calls:\n"; echo 'Difference in milliseconds: '; var_dump($named_delta[0] - $static_delta[0]); echo 'Difference in memory usage: '; var_dump($named_delta[1] - $static_delta[1]); echo "-----------------------------\n"; }; $test(1); $test(10); $test(100); $test(1000); $test(10000); $test(100000);

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.3.10.0070.04016.20
7.3.00.0070.04016.19
7.2.130.0060.03816.58
7.2.120.0070.05916.56
7.2.110.0580.04915.53
7.2.100.0820.03515.50
7.2.90.0470.04215.74
7.2.80.0470.03715.77
7.2.70.0360.03615.86
7.2.60.0880.03415.59
7.2.50.0490.03815.60
7.2.40.0480.03415.64
7.2.30.0500.03415.81
7.2.20.0640.03115.62
7.2.10.0510.03415.70
7.2.00.0510.03615.74
7.1.250.0000.06315.68
7.1.230.0770.02914.22
7.1.220.1050.04313.86
7.1.210.0830.05813.75
7.1.200.0910.03313.90
7.1.190.0390.03914.05
7.1.180.1090.02713.93
7.1.170.1330.04413.59
7.1.160.0350.04213.93
7.1.150.0850.04613.46
7.1.140.1340.06114.08
7.1.130.0870.03313.84
7.1.120.0840.05013.66
7.1.110.1260.03113.93
7.1.100.0790.03713.84
7.1.90.0940.07113.84
7.1.80.0950.03313.91
7.1.70.0940.03213.79
7.1.60.0940.03031.74
7.1.50.0950.03131.94
7.1.40.1640.03731.57
7.1.30.1490.03131.40
7.1.20.0840.03431.90
7.1.10.0980.03013.98
7.1.00.0990.03613.98
5.6.380.0130.08914.57

preferences:
43.4 ms | 403 KiB | 5 Q