3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Magic { private string $foo; private int $bar; public function __get($name) { return $this->$name; } public function __set($name, $value) { return $this->$name = $value; } } class ReflectionTest { private string $foo; private int $bar; } $m = new Magic; $start = microtime(true); for ($i=0;$i<100000;$i++) { $m->foo = 'foo'; $m->bar = 5; } printf('Magic Time taken: %0.4fs%s', microtime(true) - $start, PHP_EOL); $reflection = new ReflectionTest; $start = microtime(true); for ($i=0;$i<100000;$i++) { $foo = new \ReflectionProperty(ReflectionTest::class, 'foo'); $bar = new \ReflectionProperty(ReflectionTest::class, 'bar'); $foo->setAccessible(true); $bar->setAccessible(true); $foo->setValue($reflection, 'foo'); $bar->setValue($reflection, 5); } printf('Reflection Time taken: %0.4fs%s', microtime(true) - $start, PHP_EOL); $reflection = new ReflectionTest; $start = microtime(true); $foo = new \ReflectionProperty(ReflectionTest::class, 'foo'); $bar = new \ReflectionProperty(ReflectionTest::class, 'bar'); $foo->setAccessible(true); $bar->setAccessible(true); for ($i=0;$i<100000;$i++) { $foo->setValue($reflection, 'foo'); $bar->setValue($reflection, 5); } printf('Reflection Time (Cached) taken: %0.4fs%s', microtime(true) - $start, PHP_EOL);

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.0.100.0020.09716.84
8.0.90.0000.10116.95
8.0.80.0000.09917.00
8.0.70.0030.09516.92
8.0.60.0100.09416.72
8.0.50.0100.08716.95
8.0.30.0070.09316.92
8.0.20.0030.09616.99
8.0.10.0030.09516.96
8.0.00.0070.09616.98
7.4.230.0030.10216.58
7.4.220.0000.10316.55
7.4.210.0100.09316.66
7.4.200.0070.10016.50
7.4.190.0030.10216.64
7.4.180.0100.09716.81
7.4.160.0070.10016.62
7.4.150.0000.10316.53
7.4.140.0000.10516.41
7.4.130.0070.09916.69
7.4.120.0070.09616.25
7.4.110.0000.10316.41
7.4.100.0030.09916.61
7.4.90.0030.10016.50
7.4.80.0030.09916.61
7.4.70.0000.10616.60
7.4.60.0070.10016.49
7.4.50.0070.09816.63
7.4.40.0070.09816.24
7.4.30.0070.09616.42
7.4.20.0000.10916.41
7.4.10.0000.10116.58
7.4.00.0030.10016.31
7.3.300.0020.00516.18
7.3.290.0030.00316.19
7.3.280.0000.00616.20
7.3.270.0000.00616.15
7.3.260.0040.00416.19
7.3.250.0060.00316.14
7.3.240.0000.00716.21
7.3.230.0070.00016.01
7.3.220.0040.00416.02
7.3.210.0070.00016.14
7.3.200.0000.00616.02
7.3.190.0000.00616.02
7.3.180.0030.00316.06
7.3.170.0050.00216.03
7.3.160.0000.00615.94
7.3.150.0000.00716.11
7.3.140.0000.00616.07
7.3.130.0060.00016.09
7.3.120.0030.00316.11
7.3.110.0040.00415.95
7.3.100.0000.00715.85
7.3.90.0000.00616.36
7.3.80.0000.00616.11
7.3.70.0050.00216.18
7.3.60.0060.00016.26
7.3.50.0000.00616.22
7.3.40.0040.00416.15
7.3.30.0000.00716.22
7.3.20.0000.00718.07
7.3.10.0040.00418.05
7.3.00.0070.00018.09

preferences:
35.59 ms | 403 KiB | 5 Q