3v4l.org

run code in 300+ PHP versions simultaneously
<?php version_compare(PHP_VERSION, '7.1', '>=') || die; class MyClass { public static function callStatic($arg, $i) { return sprintf("%s %d\n", $arg, $i); } public function callable($arg, $i) { return sprintf("%s %d\n", $arg, $i); } public static function getCallable() { return [new static(), 'callable']; } public static function getClosure() { return Closure::fromCallable([new static(), 'callable']); } } function callFunc($arg, $i) { return sprintf("%s %d\n", $arg, $i); } $nTests = 100000; $result = 0; foreach([ 'callable' => MyClass::getCallable(), 'closure ' => MyClass::getClosure(), 'callstat' => ['MyClass', 'callStatic'], 'csclosed' => Closure::fromCallable(['MyClass', 'callStatic']), 'function' => 'callFunc', 'fnclosed' => Closure::fromCallable('callFunc'), ] as $name => $function) { ob_start(); $_start = microtime(true); for($i = 0; $i < $nTests; $i++) { $function('callable', $i); } $_end = microtime(true); ob_end_clean(); $_runtime = $_end - $_start; printf("%s in %.4f sec, %5.1f\n", $name, $_runtime, ($result & 1) * 100 * ($_runtime / ($_old ?? $_runtime))); $_old = $_runtime; $result++; }

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.0030.17814.93
7.3.120.0070.15014.95
7.3.110.0160.21215.20
7.3.100.0070.15715.07
7.3.90.0070.15915.06
7.3.80.0030.13614.84
7.3.70.0000.14014.86
7.3.60.0070.12814.58
7.3.50.0000.13014.73
7.3.40.0070.17814.68
7.3.30.0070.16014.77
7.3.20.0000.13716.55
7.3.10.0000.16116.72
7.3.00.0070.12716.83
7.2.250.0100.22615.31
7.2.240.0100.23215.05
7.2.230.0100.14815.21
7.2.220.0100.15415.27
7.2.210.0070.15015.11
7.2.200.0030.16115.03
7.2.190.0030.15615.04
7.2.180.0070.15115.28
7.2.170.0070.17415.12
7.1.330.0000.23816.05
7.1.320.0070.23215.80
7.1.310.0100.20415.97
7.1.300.0030.20515.99
7.1.290.0070.20915.86
7.1.280.0030.20415.64
7.1.270.0030.24615.85
7.1.260.0030.20115.93
7.1.70.0130.11017.22
7.1.60.0500.16733.35
7.1.50.0430.14333.12
7.1.40.0500.15332.57
7.1.30.0500.13032.87
7.1.20.0430.20332.85
7.1.10.0370.14714.97
7.1.00.0270.14714.91
7.0.200.0300.01014.77
7.0.190.0300.01014.89
7.0.180.0300.01014.23
7.0.170.0270.01014.23
7.0.160.0400.00714.22
7.0.150.0370.00714.24
7.0.140.0370.01014.44
7.0.130.0370.01314.57
7.0.120.0330.01014.50
7.0.110.0330.01014.34
7.0.100.0430.00714.65
7.0.90.0030.01014.50
7.0.80.0230.01314.39
7.0.70.0530.01014.17
7.0.60.0470.01014.20
7.0.50.0330.01314.66
7.0.40.0500.01314.50
7.0.30.0530.01014.47
7.0.20.0330.00714.45
7.0.10.0230.01014.52
7.0.00.0230.01014.67

preferences:
33.78 ms | 401 KiB | 5 Q