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($aBar); } $t2 = microtime(true); echo 'newinstanceargs: ' . ($t2-$t1) . "\n\n"; $t1 = microtime(true); for ($i = 0; $i < 10000; $i++) { $foo = $reflect->newInstanceWithoutConstructor(); $constructor->invokeArgs($foo, $aBar); } $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 'new keyword 2: ' . ($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.4.10.0040.02614.92
7.4.00.0060.02215.06
7.3.130.0070.02315.09
7.3.120.0130.01614.62
7.3.110.0030.02014.67
7.3.100.0000.02214.81
7.3.90.0070.01415.02
7.3.80.0040.01815.22
7.3.70.0070.01314.78
7.3.60.0060.01614.65
7.3.50.0000.02114.91
7.3.40.0160.00614.91
7.3.30.0070.01314.83
7.3.20.0100.01316.49
7.3.10.0040.01816.71
7.3.00.0070.01416.68
7.2.260.0130.01014.92
7.2.250.0140.01415.12
7.2.240.0150.00914.97
7.2.230.0030.01615.26
7.2.220.0070.01615.27
7.2.210.0070.01615.23
7.2.200.0000.01815.10
7.2.190.0090.01215.17
7.2.180.0040.01415.11
7.2.170.0000.02114.85
7.2.160.0120.00914.98
7.2.150.0080.01517.12
7.2.140.0060.01616.63
7.2.130.0100.01416.82
7.2.120.0110.01416.88
7.2.110.0000.02216.94
7.2.100.0000.02516.97
7.2.90.0070.01717.11
7.2.80.0070.01716.77
7.2.70.0030.01716.84
7.2.60.0060.01617.06
7.2.50.0040.02216.73
7.2.40.0040.01416.86
7.2.30.0090.01216.92
7.2.20.0040.01416.79
7.2.10.0040.02116.68
7.2.00.0070.01618.27
7.1.330.0060.01915.66
7.1.320.0000.02215.88
7.1.310.0030.02415.93
7.1.300.0070.01815.89
7.1.290.0070.02015.88
7.1.280.0030.02415.50
7.1.270.0070.01615.78
7.1.260.0030.02315.88
7.1.250.0060.01915.88
7.1.240.0040.02215.83
7.1.230.0060.01615.68
7.1.220.0000.02615.53
7.1.210.0070.02015.44
7.1.200.0030.02415.80
7.1.190.0040.02115.64
7.1.180.0000.02915.89
7.1.170.0060.02215.89
7.1.160.0070.01815.75
7.1.150.0070.01715.54
7.1.140.0030.02015.83
7.1.130.0040.02215.82
7.1.120.0130.01615.83
7.1.110.0030.02115.66
7.1.100.0100.02015.86
7.1.90.0030.02415.76
7.1.80.0070.02015.91
7.1.70.0080.01216.41
7.1.60.0050.02117.53
7.1.50.0070.02416.41
7.1.40.0100.01915.73
7.1.30.0130.01615.63
7.1.20.0100.01715.89
7.1.10.0100.01915.88
7.1.00.0000.06019.20
7.0.330.0030.02315.53
7.0.320.0000.02615.27
7.0.310.0060.02315.13
7.0.300.0090.01215.48
7.0.290.0100.02015.19
7.0.280.0040.02515.47
7.0.270.0120.01215.47
7.0.260.0030.02315.66
7.0.250.0130.01315.47
7.0.240.0060.02215.44
7.0.230.0060.02315.62
7.0.220.0060.02115.37
7.0.210.0070.01715.57
7.0.200.0050.01516.12
7.0.190.0090.02115.56
7.0.180.0030.02415.47
7.0.170.0090.02215.61
7.0.160.0030.02215.46
7.0.150.0000.02715.44
7.0.140.0050.05018.66
7.0.130.0030.02215.36
7.0.120.0060.02315.27
7.0.110.0030.02315.25
7.0.100.0130.01615.57
7.0.90.0040.02215.20
7.0.80.0090.01815.58
7.0.70.0100.02015.49
7.0.60.0050.05417.59
7.0.50.0080.03716.83
7.0.40.0100.05516.94
7.0.30.0100.03916.85
7.0.20.0170.04516.76
7.0.10.0080.04016.85
7.0.00.0050.04216.88
5.6.400.0070.03614.58
5.6.390.0100.02814.28
5.6.380.0030.03414.39
5.6.370.0100.02914.29
5.6.360.0000.04114.62
5.6.350.0030.03414.52
5.6.340.0000.04014.65
5.6.330.0100.02914.38
5.6.320.0100.02914.42
5.6.310.0000.04014.30
5.6.300.0060.02914.17
5.6.290.0030.03214.53
5.6.280.0000.06717.71
5.6.270.0000.03614.32
5.6.260.0030.03514.58
5.6.250.0100.02914.54
5.6.240.0070.03614.33
5.6.230.0110.03314.15
5.6.220.0070.02914.21
5.6.210.0070.06017.71
5.6.200.0060.06616.43
5.6.190.0070.06917.53
5.6.180.0180.04317.60
5.6.170.0150.07017.35
5.6.160.0070.07117.48
5.6.150.0080.06616.25
5.6.140.0050.05116.27
5.6.130.0050.06616.29
5.6.120.0080.06417.72
5.6.110.0120.06617.66
5.6.100.0050.07317.81
5.6.90.0080.04917.65
5.6.80.0070.07017.33
5.6.70.0040.02814.01
5.6.60.0040.03514.59
5.6.50.0090.02814.21
5.6.40.0060.02814.16
5.6.30.0040.03314.41
5.6.20.0070.03514.40
5.6.10.0100.03014.26
5.6.00.0070.02414.17
5.5.380.0060.00914.27
5.5.370.0040.01114.25
5.5.360.0000.01514.02
5.5.350.0180.03617.38
5.5.340.0100.02015.99
5.5.330.0050.03117.13
5.5.320.0190.04017.06
5.5.310.0080.05617.09
5.5.300.0100.03915.97
5.5.290.0020.04515.96
5.5.280.0050.05017.43
5.5.270.0080.03017.31
5.5.260.0080.03817.50
5.5.250.0110.03517.38
5.5.240.0050.02117.06
5.5.230.0070.00314.18
5.5.220.0070.00714.11
5.5.210.0040.00813.77
5.5.200.0060.00314.16
5.5.190.0100.00314.11
5.5.180.0050.00314.08
5.5.170.0030.01014.07
5.5.160.0040.00714.05
5.5.150.0030.00613.92
5.5.140.0030.00713.73
5.5.130.0070.00713.97
5.5.120.0070.00713.97
5.5.110.0100.00014.12
5.5.100.0030.00614.13
5.5.90.0060.00313.77
5.5.80.0000.01513.87
5.5.70.0090.00614.05
5.5.60.0030.01313.61
5.5.50.0040.01213.96
5.5.40.0030.00813.87
5.5.30.0060.00314.27
5.5.20.0030.00914.11
5.5.10.0100.00713.79
5.5.00.0040.01413.80
5.4.450.0210.02315.64
5.4.440.0320.02615.61
5.4.430.0070.03315.67
5.4.420.0170.02515.48
5.4.410.0100.02515.43
5.4.400.0160.02215.45
5.4.390.0420.02115.47
5.4.380.0520.03115.20
5.4.370.0580.02515.14
5.4.360.0480.03215.29
5.4.350.0450.03215.31
5.4.340.0530.02815.29
5.4.330.0030.01011.80
5.4.320.0080.01712.16
5.4.310.0070.02012.16
5.4.300.0020.02412.16
5.4.290.0010.02612.16
5.4.280.0060.02112.11
5.4.270.0060.01912.11
5.4.260.0060.02112.11
5.4.250.0060.02512.11
5.4.240.0050.01912.11
5.4.230.0060.02112.11
5.4.220.0070.01812.11
5.4.210.0050.02112.11
5.4.200.0050.02012.10
5.4.190.0040.02412.10
5.4.180.0080.01912.10
5.4.170.0020.02712.11
5.4.160.0040.02512.11
5.4.150.0020.02312.10
5.4.140.0070.02211.95
5.4.130.0050.02111.94
5.4.120.0090.01811.92
5.4.110.0090.01611.92
5.4.100.0050.02011.92
5.4.90.0040.02411.92
5.4.80.0020.02711.92
5.4.70.0060.02411.92
5.4.60.0060.02411.92
5.4.50.0100.02011.92
5.4.40.0020.02411.91
5.4.30.0050.02211.91
5.4.20.0050.02311.91
5.4.10.0050.02211.91
5.4.00.0040.02311.66
5.3.290.0050.04212.80
5.3.280.0040.04012.71
5.3.270.0050.03912.72
5.3.260.0040.04012.72
5.3.250.0060.03612.72
5.3.240.0060.03712.72
5.3.230.0080.03512.71
5.3.220.0040.03812.68
5.3.210.0060.03812.68
5.3.200.0100.03312.68
5.3.190.0080.03512.68
5.3.180.0060.03912.67
5.3.170.0110.03312.66
5.3.160.0080.03712.67
5.3.150.0080.03912.68
5.3.140.0070.03612.66
5.3.130.0040.04912.65
5.3.120.0050.03912.66
5.3.110.0040.04112.66
5.3.100.0080.03512.12
5.3.90.0070.04412.10
5.3.80.0050.03712.10
5.3.70.0060.03912.09
5.3.60.0050.03712.08
5.3.50.0050.03712.03
5.3.40.0060.03612.03
5.3.30.0040.03511.98
5.3.20.0070.03411.77
5.3.10.0070.03311.73
5.3.00.0040.03711.72
5.2.170.0060.0299.23
5.2.160.0040.0299.22
5.2.150.0080.0289.22
5.2.140.0040.0309.22
5.2.130.0030.0309.18
5.2.120.0080.0249.18
5.2.110.0040.0299.19
5.2.100.0040.0289.18
5.2.90.0040.0289.18
5.2.80.0060.0289.18
5.2.70.0040.0309.18
5.2.60.0040.0309.13
5.2.50.0060.0309.10
5.2.40.0070.0269.07
5.2.30.0060.0279.05
5.2.20.0070.0269.04
5.2.10.0040.0288.96
5.2.00.0030.0308.81
5.1.60.0080.0208.09
5.1.50.0050.0228.09
5.1.40.0060.0218.07
5.1.30.0060.0238.42
5.1.20.0070.0238.44
5.1.10.0060.0248.17
5.1.00.0040.0258.17
5.0.50.0020.0216.65
5.0.40.0020.0206.51
5.0.30.0020.0326.32
5.0.20.0010.0216.29
5.0.10.0060.0206.27
5.0.00.0030.0306.25
4.4.90.0030.0144.78
4.4.80.0020.0154.76
4.4.70.0030.0154.75
4.4.60.0020.0164.75
4.4.50.0040.0184.77
4.4.40.0040.0254.71
4.4.30.0020.0154.76
4.4.20.0030.0144.84
4.4.10.0040.0144.85
4.4.00.0020.0254.76
4.3.110.0030.0154.67
4.3.100.0020.0154.67
4.3.90.0020.0144.63
4.3.80.0030.0234.59
4.3.70.0030.0144.63
4.3.60.0020.0154.63
4.3.50.0040.0144.63
4.3.40.0020.0244.54
4.3.30.0010.0173.30
4.3.20.0020.0163.28
4.3.10.0020.0163.24
4.3.00.0000.02315.97

preferences:
32.27 ms | 401 KiB | 5 Q