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; $aBar = [$bar]; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = new Foo($bar); } $t2 = microtime(true); echo 'new keyword: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceArgs([$bar]); } $t2 = microtime(true); echo 'newinstanceargs: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceWithoutConstructor(); $constructor->invokeArgs($foo, [$bar]); } $t2 = microtime(true); echo 'newinstancewithoutconstructor: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = new Foo(...$aBar); } $t2 = microtime(true); echo 'vradic: ' . ($t2-$t1) . "\n\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)
7.2.00.0070.01719.38
7.1.70.0030.01616.92
7.1.60.0130.02619.40
7.1.50.0070.03317.05
7.1.00.0100.08322.33
7.0.200.0070.01316.91
7.0.140.0030.08321.95
7.0.60.0030.10320.10
7.0.50.0030.09017.91
7.0.40.0070.09020.40
7.0.30.0330.08320.10
7.0.20.0300.06320.20
7.0.10.0070.10720.19
7.0.00.0100.09020.10
5.6.280.0030.10321.11
5.6.210.0100.10320.72
5.6.200.0130.10018.29
5.6.190.0070.09020.46
5.6.180.0270.05320.50
5.6.170.0200.07020.52
5.6.160.0100.11020.55
5.6.150.0000.06718.25
5.6.140.0100.05018.23
5.6.130.0100.08718.18
5.6.120.0070.08721.13
5.6.110.0070.05720.99
5.6.100.0130.08320.98
5.6.90.0100.11021.09
5.6.80.0100.06720.37
5.5.350.0330.07320.44
5.5.340.0070.04318.11
5.5.330.0000.05020.37
5.5.320.0200.08020.27
5.5.310.0200.04320.37
5.5.300.0030.07317.95
5.5.290.0170.07317.95
5.5.280.0000.05320.81
5.5.270.0100.06020.88
5.5.260.0070.08720.66
5.5.250.0070.03720.63
5.5.240.0100.06320.20
5.4.450.0800.05319.69
5.4.440.0500.05719.32
5.4.430.0630.06019.43
5.4.420.0330.05019.31
5.4.410.0830.04019.10
5.4.400.0470.07018.87
5.4.390.0330.05318.54
5.4.380.0270.06318.49
5.4.370.0170.05018.63
5.4.360.0230.03018.79
5.4.350.0090.05512.04
5.4.340.0060.03912.04
5.4.320.0070.03612.53
5.4.310.0100.04512.52
5.4.300.0030.03912.53
5.4.290.0050.04012.52
5.4.280.0070.03612.42
5.4.270.0050.04012.41
5.4.260.0030.04012.42
5.4.250.0040.03812.41
5.4.240.0050.03612.41
5.4.230.0020.04212.41
5.4.220.0120.04912.41
5.4.210.0070.03412.41
5.4.200.0060.04812.41
5.4.190.0110.03912.40
5.4.180.0030.04712.41
5.4.170.0060.03712.41
5.4.160.0070.04212.41
5.4.150.0110.03612.41
5.4.140.0060.03512.09
5.4.130.0050.03512.07
5.4.120.0050.03512.04
5.4.110.0070.03312.04
5.4.100.0050.03912.04
5.4.90.0120.03412.04
5.4.80.0080.03712.04
5.4.70.0040.03512.04
5.4.60.0050.03412.04
5.4.50.0080.03212.03
5.4.40.0030.03812.02
5.4.30.0040.03712.02
5.4.20.0080.03412.01
5.4.10.0090.04212.02
5.4.00.0060.03811.51
5.3.290.0040.03912.80
5.3.280.0060.03612.71
5.3.270.0080.04212.72
5.3.260.0080.03912.72
5.3.250.0020.04012.72
5.3.240.0100.03312.72
5.3.230.0070.03612.71
5.3.220.0100.04012.68
5.3.210.0070.03712.68
5.3.200.0060.03612.68
5.3.190.0040.03812.68
5.3.180.0070.03512.67
5.3.170.0040.03712.67
5.3.160.0010.04512.67
5.3.150.0060.04912.67
5.3.140.0060.04112.66
5.3.130.0040.04112.66
5.3.120.0050.03812.66
5.3.110.0080.04012.66
5.3.100.0060.03512.12
5.3.90.0050.03612.11
5.3.80.0080.03312.09
5.3.70.0050.03612.09
5.3.60.0090.03212.08
5.3.50.0100.03512.03
5.3.40.0050.03712.03
5.3.30.0060.04011.99
5.3.20.0050.03511.77
5.3.10.0060.03411.73
5.3.00.0040.03911.72
5.2.170.0070.0329.23
5.2.160.0080.0289.23
5.2.150.0050.0369.23
5.2.140.0060.0319.22
5.2.130.0030.0409.18
5.2.120.0030.0329.18
5.2.110.0040.0299.19
5.2.100.0060.0289.18
5.2.90.0060.0279.18
5.2.80.0050.0319.18
5.2.70.0040.0309.18
5.2.60.0030.0359.13
5.2.50.0090.0289.10
5.2.40.0040.0289.07
5.2.30.0050.0329.05
5.2.20.0060.0279.04
5.2.10.0040.0288.94
5.2.00.0030.0308.81
5.1.60.0060.0228.09
5.1.50.0030.0258.09
5.1.40.0040.0248.07
5.1.30.0020.0288.43
5.1.20.0020.0288.45
5.1.10.0020.0278.17
5.1.00.0030.0268.17
5.0.50.0050.0196.64
5.0.40.0020.0216.51
5.0.30.0020.0326.32
5.0.20.0020.0226.28
5.0.10.0020.0216.26
5.0.00.0020.0326.25
4.4.90.0010.0174.78
4.4.80.0020.0164.75
4.4.70.0030.0144.76
4.4.60.0020.0214.75
4.4.50.0020.0154.77
4.4.40.0060.0214.71
4.4.30.0040.0144.76
4.4.20.0040.0144.84
4.4.10.0030.0164.85
4.4.00.0040.0284.76
4.3.110.0030.0154.66
4.3.100.0010.0164.66
4.3.90.0020.0164.64
4.3.80.0020.0264.59
4.3.70.0020.0154.63
4.3.60.0030.0174.63
4.3.50.0040.0144.63
4.3.40.0040.0224.54
4.3.30.0030.0163.30
4.3.20.0030.0193.28
4.3.10.0010.0183.23
4.3.00.0130.0237.11

preferences:
30.34 ms | 400 KiB | 5 Q