3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (PHP_VERSION !== '7.2.0alpha2') die('Meh'); function test($label = '') { global $t; $t2 = microtime(1); if ($label) echo str_pad($label . ': ', 32, '.', STR_PAD_RIGHT) . ' ' . 1000 * ($t2 - $t) . 'ms' . "\n"; $t = $t2; } $c = 1; $c2 = 10000; // --------------------- class Meh { function hem() { return 1; } } class MehBag { public $meh1, $meh2, $meh3; function __construct(Meh $meh) { $this->meh1 = $meh; $this->meh2 = $meh; $this->meh3 = $meh; } } $x1 = function (Meh $meh1, Meh $meh2, Meh $meh3) { return $meh1->hem() + $meh2->hem() + $meh3->hem(); }; $x2 = function (MehBag $bag) { return $bag->meh1->hem() + $bag->meh2->hem() + $bag->meh3->hem(); }; // --------------------- test(); for ($i = $c; $i--;) { for ($j = $c2; $j--;) { $rc = new \ReflectionFunction($x1); $rp = $rc->getParameters(); $bag = [ Meh::class => new Meh() ]; $args = []; foreach ($rp as $p) { $pc = $p->getClass(); $name = $pc->name ?? null; if ($name) $args[] = $bag[$name]; } $result1 = $x1(...$args); } } test('ref'); for ($i = $c; $i--;) { for ($j = $c2; $j--;) { $bag = new MehBag(new Meh()); $result2 = $x2($bag); } } test('bag'); var_dump($result1); var_dump($result2);

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.1.70.0050.00516.85
7.1.60.0110.00416.99
7.1.50.0110.00316.50
7.1.40.0040.00816.52
7.1.30.0090.00616.53
7.1.20.0100.00816.55
7.1.10.0060.00616.26
7.1.00.0030.00616.77
7.0.200.0000.00916.66
7.0.190.0000.00916.66
7.0.180.0000.00916.20
7.0.170.0070.00716.24
7.0.160.0080.00416.26
7.0.150.0030.00716.22
7.0.140.0060.00616.06
7.0.130.0100.00316.26
7.0.120.0080.00416.43
7.0.110.0030.01016.16
7.0.100.0000.01216.28
7.0.90.0100.00516.18
7.0.80.0070.01016.11
7.0.70.0050.00816.13
7.0.60.0060.00915.97
7.0.50.0100.00016.38
7.0.40.0030.00715.26
7.0.30.0000.00815.26
7.0.20.0000.01015.26
7.0.10.0000.00915.26
7.0.00.0030.00615.26

preferences:
33.98 ms | 400 KiB | 5 Q