3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { } class Foo { private $bar; public function __construct(Bar $bar) { $this->bar = $bar; } } $reflect = new ReflectionClass('foo'); $constructor = $reflect->getConstructor(); $bar = new Bar; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = new Foo($bar); } $t2 = microtime(true); echo 'new keyword: ' . ($t2-$t1) . '<br />'; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceArgs([$bar]); } $t2 = microtime(true); echo 'newinstanceargs: ' . ($t2-$t1) . '<br />'; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceWithoutConstructor(); $constructor->invokeArgs($foo, [$bar]); } $t2 = microtime(true); echo 'newinstancewithoutconstructor: ' . ($t2-$t1) . '<br />';

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.2.00.0030.01219.48
7.1.70.0000.02817.32
7.1.60.0030.03419.40
7.1.50.0110.02816.98
7.1.00.0100.08022.27
7.0.200.0100.00716.95
7.0.140.0030.08022.07
7.0.100.0200.05720.02
7.0.90.0270.06020.03
7.0.80.0070.09019.96
7.0.70.0070.05719.96
7.0.60.0030.06320.00
7.0.50.0000.10020.33
7.0.40.0100.07720.18
7.0.30.0070.09720.11
7.0.20.0070.09019.98
7.0.10.0070.09320.18
7.0.00.0100.09020.09
5.6.280.0030.09720.94
5.6.250.0030.10320.60
5.6.240.0070.06720.61
5.6.230.0130.06720.70
5.6.220.0100.05020.67
5.6.210.0200.09320.49
5.6.200.0100.06021.09
5.6.190.0130.06020.97
5.6.180.0130.10020.96
5.6.170.0130.08720.96
5.6.160.0000.06321.09
5.6.150.0130.08321.04
5.6.140.0170.09320.96
5.6.130.0070.07021.17
5.6.120.0030.07020.95
5.6.110.0200.07321.02
5.6.100.0070.10720.93
5.6.90.0170.09321.05
5.6.80.0070.07020.35
5.6.70.0070.09720.46
5.6.60.0030.10720.39
5.6.50.0130.10020.50
5.6.40.0100.06020.43
5.6.30.0070.10320.46
5.6.20.0070.07020.53
5.6.10.0100.06020.42
5.6.00.0100.05320.38
5.5.380.0070.06720.46
5.5.370.0130.08320.46
5.5.360.0100.10320.34
5.5.350.0070.06720.48
5.5.340.0130.06020.66
5.5.330.0000.07720.92
5.5.320.0100.05720.80
5.5.310.0170.11320.84
5.5.300.0130.08020.84
5.5.290.0030.10020.77
5.5.280.0070.10020.89
5.5.270.0070.07020.91
5.5.260.0100.09720.89
5.5.250.0130.06020.58
5.5.240.0130.09720.04
5.5.230.0070.06719.96
5.5.220.0130.08720.18
5.5.210.0100.09320.18
5.5.200.0070.08720.18
5.5.190.0100.05020.28
5.5.180.0170.10020.13
5.5.160.0000.05720.24
5.5.150.0030.09320.12
5.5.140.0170.04320.11
5.5.130.0030.09720.25
5.5.120.0000.05720.09
5.5.110.0000.07720.23
5.5.100.0200.05320.03
5.5.90.0070.09720.17
5.5.80.0100.07720.18
5.5.70.0100.09720.07
5.5.60.0030.06020.09
5.5.50.0200.08020.13
5.5.40.0170.08720.02
5.5.30.0200.09020.12
5.5.20.0070.09020.13
5.5.10.0200.07020.13
5.5.00.0130.09320.11
5.4.450.0100.09719.28
5.4.440.0100.10019.38
5.4.430.0070.09719.35
5.4.420.0030.06719.35
5.4.410.0070.07319.23
5.4.400.0000.05719.18
5.4.390.0030.10319.14
5.4.380.0070.06019.13
5.4.370.0030.07019.14
5.4.360.0030.05318.91
5.4.350.0000.10319.09
5.4.340.0130.08719.13
5.4.320.0070.07019.15
5.4.310.0070.05319.04
5.4.300.0030.11019.03
5.4.290.0130.08718.87
5.4.280.0030.10719.17
5.4.270.0030.09318.85
5.4.260.0200.08018.88
5.4.250.0030.08719.22
5.4.240.0030.08319.15
5.4.230.0030.09019.20
5.4.220.0070.09019.16
5.4.210.0100.10019.04
5.4.200.0100.09019.15
5.4.190.0130.07019.02
5.4.180.0100.09719.02
5.4.170.0200.08719.09
5.4.160.0130.06319.07
5.4.150.0070.09719.16
5.4.140.0030.09716.39
5.4.130.0200.08316.24
5.4.120.0100.09016.48
5.4.110.0070.09316.39
5.4.100.0100.05716.32
5.4.90.0100.07016.52
5.4.80.0100.05016.51
5.4.70.0070.08316.40
5.4.60.0100.08316.29
5.4.50.0030.09016.46
5.4.40.0100.09016.35
5.4.30.0070.08716.43
5.4.20.0130.08016.36
5.4.10.0000.07316.33
5.4.00.0030.06715.94
5.3.290.0030.06714.69
5.3.280.0030.08714.63
5.3.270.0070.06714.63
5.3.260.0030.04714.61
5.3.250.0070.08014.67
5.3.240.0070.05314.60
5.3.230.0030.08014.66
5.3.220.0100.07714.63
5.3.210.0030.05014.67
5.3.200.0070.07314.66
5.3.190.0100.06714.69
5.3.180.0070.08014.68
5.3.170.0070.04714.59
5.3.160.0100.06714.69
5.3.150.0030.07314.54
5.3.140.0070.03314.58
5.3.130.0100.06314.51
5.3.120.0100.06314.62
5.3.110.0000.07314.67
5.3.100.0070.06714.01
5.3.90.0070.07013.95
5.3.80.0070.06314.07
5.3.70.0070.07313.94
5.3.60.0030.07314.02
5.3.50.0070.07014.01
5.3.40.0070.04013.84
5.3.30.0200.05313.93
5.3.20.0070.05013.76
5.3.10.0030.03713.72
5.3.00.0170.06013.69
5.2.170.0030.03311.20
5.2.160.0030.04011.21
5.2.150.0070.05711.20
5.2.140.0030.04011.17
5.2.130.0030.05311.02
5.2.120.0100.05311.13
5.2.110.0000.03311.24
5.2.100.0000.03711.22
5.2.90.0030.03011.11
5.2.80.0000.03711.22
5.2.70.0070.03311.03
5.2.60.0030.06011.05
5.2.50.0000.03710.88
5.2.40.0000.03310.93
5.2.30.0070.06310.88
5.2.20.0070.05710.84
5.2.10.0100.03010.72
5.2.00.0070.06010.77
5.1.60.0030.0579.84
5.1.50.0030.06010.10
5.1.40.0070.05310.08
5.1.30.0070.05310.48
5.1.20.0030.03010.38
5.1.10.0000.04710.16
5.1.00.0070.05310.06
5.0.50.0030.0209.60
5.0.40.0070.0279.60
5.0.30.0000.0609.60
5.0.20.0030.0339.60
5.0.10.0000.0379.60
5.0.00.0030.0339.60
4.4.90.0130.0039.60
4.4.80.0000.0179.60
4.4.70.0000.0179.60
4.4.60.0000.0439.60
4.4.50.0030.0339.60
4.4.40.0000.0439.60
4.4.30.0030.0339.60
4.4.20.0000.0279.60
4.4.10.0070.0309.60
4.4.00.0030.0539.60
4.3.110.0030.0179.60
4.3.100.0030.0309.60
4.3.90.0030.0339.60
4.3.80.0030.0509.60
4.3.70.0030.0139.60
4.3.60.0030.0339.60
4.3.50.0030.0309.60
4.3.40.0070.0509.60
4.3.30.0000.0179.60
4.3.20.0000.0379.60
4.3.10.0030.0279.60
4.3.00.0000.0179.60

preferences:
36.06 ms | 400 KiB | 5 Q