public static function timeFunc($iterations, $function, &$output = null){

    $time = 0;

    for($i = 0; $i < $iterations; $i++){
      $start  = microtime(true);
      $output = call_user_func($function);
      $time  += microtime(true) - $start;
    }

    return round($time, 4);
  }
public static function timeFunc($iterations, $function, &$output = null){

    $time = 0;

    for($i = 0; $i < $iterations; $i++){
      $start  = microtime(true);
      $output = call_user_func($function);
      $time  += microtime(true) - $start;
    }

    return round($time, 4);
  }
public static function timeFunc ( $ iterations , $ function , & $ output = null ) { $ time = 0 ; for ( $ i = 0 ; $ i < $ iterations ; $ i ++ ) { $ start = microtime ( true ) ; $ output = call_user_func ( $ function ) ; $ time += microtime ( true ) - $ start ; } return round ( $ time , 4 ) ; }
Executes a function the given number of times and returns the elapsed time.

Keep in mind that the returned time includes function call overhead (including
microtime calls) x iteration count. This is why this is better suited for
determining which of two or more functions is the fastest, rather than
finding out how fast is a single function.

@param   int $iterations      Number of times the function will be executed
@param   callable $function   Function to execute
@param   mixed &$output       If given, last return value will be available in this variable
@return  double               Elapsed time
Executes a function the given number of times and returns the elapsed time .