3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Test { private $arguments = array(1,2,3); public function foo() { $closureToCall = 'max'; //this function accepts multiple args $start = microtime(true); for ($i=0; $i<1e5; $i++) { $args = $this->arguments; switch (count($args)) { case 0: $closureToCall();break; case 1: $closureToCall($args[0]);break; case 2: $closureToCall($args[0], $args[1]);break; case 3: $closureToCall($args[0], $args[1], $args[2]);break; case 4: $closureToCall($args[0], $args[1], $args[2], $args[3]);break; case 5: $closureToCall($args[0], $args[1], $args[2], $args[3], $args[4]);break; default: forward_static_call_array($closureToCall, $args); } } $end = microtime(true); echo "Took: ", ($end-$start)*1e3, " ms"; $start = microtime(true); for ($i=0; $i<1e5; $i++) { $args = $this->arguments; $closureToCall(...$args); } $end = microtime(true); echo "Took: ", ($end-$start)*1e3, " ms"; } } $obj = new Test; $obj->foo();
based on CpEAV
Output for 7.1.0
Took: 28.127908706665 msTook: 15.676975250244 ms
Output for 7.0.14
Took: 24.59716796875 msTook: 15.038967132568 ms
Output for 7.0.11
Took: 18.442869186401 msTook: 12.736797332764 ms
Output for 7.0.10
Took: 17.642974853516 msTook: 11.044979095459 ms
Output for 7.0.9
Took: 20.624876022339 msTook: 12.797117233276 ms
Output for 7.0.8
Took: 18.586158752441 msTook: 11.668920516968 ms
Output for 7.0.7
Took: 14.698028564453 msTook: 10.379076004028 ms
Output for 7.0.6
Took: 18.934965133667 msTook: 11.950969696045 ms
Output for 7.0.5
Took: 17.568111419678 msTook: 9.5150470733643 ms
Output for 7.0.4
Took: 21.486043930054 msTook: 13.052940368652 ms
Output for 7.0.3
Took: 13.098001480103 msTook: 7.9758167266846 ms
Output for 7.0.2
Took: 19.37198638916 msTook: 12.367963790894 ms
Output for 7.0.1
Took: 20.066976547241 msTook: 11.941909790039 ms
Output for 7.0.0
Took: 17.338037490845 msTook: 9.1679096221924 ms
Output for 5.6.28
Took: 14.960050582886 msTook: -24.672985076904 ms
Output for 5.6.26
Took: 32.190799713135 msTook: 18.308877944946 ms
Output for 5.6.25
Took: 43.404102325439 msTook: 22.531986236572 ms
Output for 5.6.24
Took: 47.029972076416 msTook: 23.853063583374 ms
Output for 5.6.23
Took: 42.937994003296 msTook: 22.779941558838 ms
Output for 5.6.22
Took: 49.669981002808 msTook: 25.12001991272 ms
Output for 5.6.21
Took: 42.370080947876 msTook: 22.653102874756 ms
Output for 5.6.20
Took: 36.945104598999 msTook: 20.483016967773 ms
Output for 5.6.19
Took: 38.82098197937 msTook: 20.664215087891 ms
Output for 5.6.18
Took: 42.630910873413 msTook: 22.771120071411 ms
Output for 5.6.17
Took: 44.920921325684 msTook: 23.297071456909 ms
Output for 5.6.16
Took: 49.474000930786 msTook: 24.955987930298 ms
Output for 5.6.15
Took: 45.207977294922 msTook: 23.179054260254 ms
Output for 5.6.14
Took: 37.914991378784 msTook: 18.430948257446 ms
Output for 5.6.13
Took: 39.979934692383 msTook: 20.740985870361 ms
Output for 5.6.12
Took: 31.919002532959 msTook: 18.474102020264 ms
Output for 5.6.11
Took: 38.674116134644 msTook: 20.381927490234 ms
Output for 5.6.10
Took: 37.738084793091 msTook: 18.769979476929 ms
Output for 5.6.9
Took: 64.662218093872 msTook: 29.553890228271 ms
Output for 5.6.8
Took: 41.654109954834 msTook: 19.165992736816 ms
Output for 5.6.7
Took: 44.941902160645 msTook: 22.361993789673 ms
Output for 5.6.6
Took: 33.78701210022 msTook: 17.960071563721 ms
Output for 5.6.5
Took: 40.428876876831 msTook: 18.567800521851 ms
Output for 5.6.4
Took: 43.956995010376 msTook: 20.170211791992 ms
Output for 5.6.3
Took: 44.306993484497 msTook: 23.206949234009 ms
Output for 5.6.2
Took: 39.191007614136 msTook: 18.975019454956 ms
Output for 5.6.1
Took: 43.418884277344 msTook: 20.298004150391 ms
Output for 5.6.0
Took: 44.557809829712 msTook: 21.392822265625 ms
Output for 5.5.0 - 5.5.38
Parse error: syntax error, unexpected '.' in /in/n0NEo on line 35
Process exited with code 255.
Output for 5.1.0 - 5.4.45
Parse error: syntax error, unexpected '.', expecting ')' in /in/n0NEo on line 35
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected '.', expecting ')' in /in/n0NEo on line 35
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/n0NEo on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/n0NEo on line 4
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/n0NEo on line 4
Process exited with code 255.