3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { private $bar = []; public function fill($limit = 100) { for ($i = 0; $i < $limit; $i++) { $this->bar[] = mt_rand($i, $limit); } } public function getEvenCounter() : Countable { return function () implements Countable { $counter = 0; foreach ($this->bar as $value) { if ($value % 2 === 0) $counter++; } return $counter; }; } public function getOddCounter() : Countable { return function () implements Countable { $counter = 0; foreach ($this->bar as $value) { if ($value % 2 !== 0) { $counter++; } } return $counter; }; } } $foo = new Foo(); $even = $foo->getEvenCounter(); $odd = $foo->getOddCounter(); $it = 0; while (++$it<10) { $foo->fill(50); var_dump( count($even), count($odd)); } ?>

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)
8.3.50.0050.00316.78
7.0.50.0130.05320.38
7.0.40.0470.05320.25
7.0.30.0470.05720.19
7.0.20.0500.05720.29
7.0.10.0300.07020.17
7.0.00.0600.07020.26
5.6.200.0130.05721.08
5.6.190.0500.04321.04
5.6.180.0400.05721.20
5.6.170.0500.04721.13
5.6.160.0170.07021.04
5.6.150.0100.05720.97
5.6.140.0300.06021.16
5.6.130.0330.06320.96
5.6.120.0130.06321.06
5.6.110.0530.04721.05
5.6.100.0500.04321.11
5.6.90.0370.06321.04
5.6.80.0430.05020.35
5.6.70.0370.04720.50
5.6.60.0470.04020.40
5.6.50.0100.05320.46
5.6.40.0130.05320.42
5.6.30.0370.04720.57
5.6.20.0230.05320.37
5.6.10.0100.05320.41
5.6.00.0170.06020.38
5.5.340.0230.05020.75
5.5.330.0400.05720.75
5.5.320.0370.05721.01
5.5.310.0500.04720.87
5.5.300.0270.05320.88
5.5.290.0500.05020.82
5.5.280.0330.06320.85
5.5.270.0400.06320.87
5.5.260.0400.05720.87
5.5.250.0400.05320.56
5.5.240.0370.05320.22
5.5.230.0330.06020.33
5.5.220.0430.04720.15
5.5.210.0200.06320.18
5.5.200.0300.05320.19
5.5.190.0370.05020.20
5.5.180.0100.05720.23
5.5.160.0300.05720.31
5.5.150.0330.05320.18
5.5.140.0300.05320.14
5.5.130.0370.04720.22
5.5.120.0330.05020.35
5.5.110.0300.06320.32
5.5.100.0330.06020.12
5.5.90.0400.05020.11
5.5.80.0530.03720.13
5.5.70.0270.06020.08
5.5.60.0330.05720.11
5.5.50.0330.05720.02
5.5.40.0470.04320.26
5.5.30.0470.04720.08
5.5.20.0430.05020.00
5.5.10.0400.05720.07
5.5.00.0300.06020.04

preferences:
41.44 ms | 739 KiB | 4 Q