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";
Output for 7.2.0
new keyword: 0.0016269683837891 newinstanceargs: 0.0028989315032959 newinstancewithoutconstructor: 0.0023899078369141 vradic: 0.0009610652923584
Output for 7.1.7
new keyword: 0.0023880004882812 newinstanceargs: 0.0028979778289795 newinstancewithoutconstructor: 0.0027849674224854 vradic: 0.0011539459228516
Output for 7.1.6
new keyword: 0.0022730827331543 newinstanceargs: 0.0052099227905273 newinstancewithoutconstructor: 0.0057101249694824 vradic: 0.0022439956665039
Output for 7.1.5
new keyword: 0.0022749900817871 newinstanceargs: 0.0053770542144775 newinstancewithoutconstructor: 0.0056729316711426 vradic: 0.0022180080413818
Output for 7.1.0
new keyword: 0.0017409324645996 newinstanceargs: 0.003666877746582 newinstancewithoutconstructor: 0.0042080879211426 vradic: 0.0017659664154053
Output for 7.0.20
new keyword: 0.0012390613555908 newinstanceargs: 0.002593994140625 newinstancewithoutconstructor: 0.0030019283294678 vradic: 0.001338005065918
Output for 7.0.14
new keyword: 0.0017900466918945 newinstanceargs: 0.0034141540527344 newinstancewithoutconstructor: 0.0043599605560303 vradic: 0.0018160343170166
Output for 7.0.6
new keyword: 0.0016510486602783 newinstanceargs: 0.0046119689941406 newinstancewithoutconstructor: 0.0040340423583984 vradic: 0.001708984375
Output for 7.0.5
new keyword: 0.0015859603881836 newinstanceargs: 0.0032649040222168 newinstancewithoutconstructor: 0.0038700103759766 vradic: 0.0016429424285889
Output for 7.0.4
new keyword: 0.0015778541564941 newinstanceargs: 0.0031869411468506 newinstancewithoutconstructor: 0.0036880970001221 vradic: 0.0016210079193115
Output for 7.0.3
new keyword: 0.0015511512756348 newinstanceargs: 0.0032141208648682 newinstancewithoutconstructor: 0.003903865814209 vradic: 0.0016119480133057
Output for 7.0.2
new keyword: 0.0018260478973389 newinstanceargs: 0.003032922744751 newinstancewithoutconstructor: 0.0034768581390381 vradic: 0.0015089511871338
Output for 7.0.1
new keyword: 0.0018270015716553 newinstanceargs: 0.0036439895629883 newinstancewithoutconstructor: 0.0042870044708252 vradic: 0.0018720626831055
Output for 7.0.0
new keyword: 0.0015649795532227 newinstanceargs: 0.0033459663391113 newinstancewithoutconstructor: 0.0039291381835938 vradic: 0.0016520023345947
Output for 5.6.28
new keyword: 0.0047647953033447 newinstanceargs: 0.0087149143218994 newinstancewithoutconstructor: 0.0098018646240234 vradic: 0.00447678565979
Output for 5.6.21
new keyword: 0.0043900012969971 newinstanceargs: 0.0082969665527344 newinstancewithoutconstructor: 0.0088751316070557 vradic: 0.0046529769897461
Output for 5.6.20
new keyword: 0.0039920806884766 newinstanceargs: 0.0079119205474854 newinstancewithoutconstructor: 0.0090270042419434 vradic: 0.0046830177307129
Output for 5.6.19
new keyword: 0.0033450126647949 newinstanceargs: 0.0059928894042969 newinstancewithoutconstructor: 0.0068609714508057 vradic: 0.0033369064331055
Output for 5.6.18
new keyword: 0.0026252269744873 newinstanceargs: 0.0046110153198242 newinstancewithoutconstructor: 0.0053789615631104 vradic: 0.0027339458465576
Output for 5.6.17
new keyword: 0.0035638809204102 newinstanceargs: 0.005748987197876 newinstancewithoutconstructor: 0.0067830085754395 vradic: 0.0053529739379883
Output for 5.6.16
new keyword: 0.0040960311889648 newinstanceargs: 0.0081160068511963 newinstancewithoutconstructor: 0.0087149143218994 vradic: 0.0047330856323242
Output for 5.6.15
new keyword: 0.0028581619262695 newinstanceargs: 0.0052409172058105 newinstancewithoutconstructor: 0.0058519840240479 vradic: 0.003262996673584
Output for 5.6.14
new keyword: 0.0026319026947021 newinstanceargs: 0.0049259662628174 newinstancewithoutconstructor: 0.005687952041626 vradic: 0.0031070709228516
Output for 5.6.13
new keyword: 0.0035688877105713 newinstanceargs: 0.007011890411377 newinstancewithoutconstructor: 0.0078451633453369 vradic: 0.0041110515594482
Output for 5.6.12
new keyword: 0.0034151077270508 newinstanceargs: 0.0066699981689453 newinstancewithoutconstructor: 0.0075998306274414 vradic: 0.0041680335998535
Output for 5.6.11
new keyword: 0.0025820732116699 newinstanceargs: 0.005363941192627 newinstancewithoutconstructor: 0.0058219432830811 vradic: 0.0035569667816162
Output for 5.6.10
new keyword: 0.0034949779510498 newinstanceargs: 0.0069959163665771 newinstancewithoutconstructor: 0.0060679912567139 vradic: 0.0044910907745361
Output for 5.6.9
new keyword: 0.003838062286377 newinstanceargs: 0.0074799060821533 newinstancewithoutconstructor: 0.0083489418029785 vradic: 0.0044698715209961
Output for 5.6.8
new keyword: 0.0029740333557129 newinstanceargs: 0.0058650970458984 newinstancewithoutconstructor: 0.0066940784454346 vradic: 0.0035481452941895
Output for 5.5.24 - 5.5.35
Parse error: syntax error, unexpected '.' in /in/3HL85 on line 56
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '.', expecting ')' in /in/3HL85 on line 56
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/3HL85 on line 19
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/3HL85 on line 19
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/3HL85 on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/3HL85 on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/3HL85 on line 7
Process exited with code 255.

preferences:
161.67 ms | 401 KiB | 174 Q