3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test() {} $nIter = 1000000; $argNums = [0, 1, 2, 3, 4, 5, 100]; $func = 'test'; foreach ($argNums as $argNum) { $args = $argNum == 0 ? [] : array_fill(0, $argNum, null); $startTime = microtime(true); for ($i = 0; $i < $nIter; ++$i) { call_user_func_array($func, $args); } $endTime = microtime(true); echo "cufa with $argNum args took ", $endTime - $startTime, "\n"; $startTime = microtime(true); for ($i = 0; $i < $nIter; ++$i) { switch (count($args)) { case 0: $func(); break; case 1: $func($args[0]); break; case 2: $func($args[0], $args[1]); break; case 3: $func($args[0], $args[1], $args[2]); break; case 4: $func($args[0], $args[1], $args[2], $args[3]); break; case 5: $func($args[0], $args[1], $args[2], $args[3], $args[4]); break; default: call_user_func_array($func, $args); break; } } $endTime = microtime(true); echo "switch with $argNum args took ", $endTime - $startTime, "\n"; $startTime = microtime(true); for ($i = 0; $i < $nIter; ++$i) { $func(...$args); } $endTime = microtime(true); echo "unpack with $argNum args took ", $endTime - $startTime, "\n"; }

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.210.0270.03718.88
5.4.200.0230.04319.13
5.4.190.0270.04019.18
5.4.180.0230.07719.14
5.4.170.0270.07719.23
5.4.160.0270.06718.97
5.4.150.0270.07019.04
5.4.140.0400.07716.52
5.4.130.0170.04316.41
5.4.120.0230.03316.41
5.4.110.0170.03716.32
5.4.100.0100.05016.57
5.4.90.0200.04716.38
5.4.80.0300.05316.34
5.4.70.0230.07016.26
5.4.60.0300.05716.33
5.4.50.0330.05316.51
5.4.40.0230.03316.40
5.4.30.0100.04316.42
5.4.20.0270.06716.37
5.4.10.0170.05716.51
5.4.00.0300.04315.97
5.3.270.0300.06715.40
5.3.260.0170.05315.40
5.3.250.0230.07015.40
5.3.240.0300.06315.40
5.3.230.0170.04715.40
5.3.220.0230.07015.40
5.3.210.0200.04315.40
5.3.200.0170.03715.40
5.3.190.0200.07715.40
5.3.180.0170.05015.40
5.3.170.0300.06315.40
5.3.160.0170.05315.40
5.3.150.0170.05015.40
5.3.140.0200.04715.40
5.3.130.0270.07015.40
5.3.120.0300.06315.40
5.3.110.0230.06715.40
5.3.100.0200.05015.40
5.3.90.0270.06015.40
5.3.80.0230.04715.40
5.3.70.0230.04315.40
5.3.60.0270.06715.40
5.3.50.0270.06315.40
5.3.40.0300.06715.40
5.3.30.0330.05015.40
5.3.20.0200.03315.40
5.3.10.0130.03715.40
5.3.00.0170.03315.40

preferences:
33.05 ms | 401 KiB | 5 Q