3v4l.org

run code in 300+ PHP versions simultaneously
<?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.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.26, 7.3.0 - 7.3.13, 7.4.0 - 7.4.1
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 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
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.2.17, 5.3.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.3.11, 4.4.0 - 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.

preferences:
245.49 ms | 401 KiB | 325 Q