3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // more info here: http://ro.php.net/manual/en/function.microtime.php // and here: http://stackoverflow.com/questions/19973037/benchmark-memory-usage-in-php // and an example here: http://3v4l.org/0ifv8 function benchmark(callable $function, $args=null, $count=1) { $time = microtime(TRUE); for($i=0; $i<$count; $i++) { $result = is_array($args)? call_user_func_array($function, $args): call_user_func_array($function); } return array( 'total_time' => microtime(TRUE) - $time, 'average_time' => (microtime(TRUE) - $time)/$count, 'count' => $count ); } function p($string) { print_r($string . "<br>"); } print( benchmark( p('t1'), array('test', 10) ) );
Output for 7.0.0 - 7.1.0
t1<br> Fatal error: Uncaught TypeError: Argument 1 passed to benchmark() must be callable, null given, called in /in/5NLYu on line 27 and defined in /in/5NLYu:6 Stack trace: #0 /in/5NLYu(27): benchmark(NULL, Array) #1 {main} thrown in /in/5NLYu on line 6
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
t1<br> Catchable fatal error: Argument 1 passed to benchmark() must be an instance of callable, null given in /in/5NLYu on line 20
Process exited with code 255.
Output for 5.4.0 - 5.6.25
t1<br> Catchable fatal error: Argument 1 passed to benchmark() must be callable, null given, called in /in/5NLYu on line 27 and defined in /in/5NLYu on line 6
Process exited with code 255.
Output for 5.2.0 - 5.3.29
t1<br> Catchable fatal error: Argument 1 passed to benchmark() must be an instance of callable, null given, called in /in/5NLYu on line 27 and defined in /in/5NLYu on line 6
Process exited with code 255.
Output for 5.1.0 - 5.1.6
t1<br> Fatal error: Argument 1 passed to benchmark() must not be null, called in /in/5NLYu on line 27 and defined in /in/5NLYu on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.5
t1<br> Fatal error: Argument 1 must not be null in /in/5NLYu on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/5NLYu on line 6
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 ')' in /in/5NLYu on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/5NLYu on line 6
Process exited with code 255.