public function profile($classname, $methodname, $methodargs, $invocations = 1)
    {
        if (class_exists($classname) != TRUE) {
            throw new Exception("{$classname} doesn't exist");
        }

        $method = new ReflectionMethod($classname, $methodname);

        $instance = NULL;
        if (!$method->isStatic()) {
            $class = new ReflectionClass($classname);
            $instance = $class->newInstance();
        }

        $durations = array();
        for ($i = 0; $i < $invocations; $i++) {
            $start = microtime(true);
            $method->invokeArgs($instance, $methodargs);
            $durations[] = microtime(true) - $start;
        }
        $durations['worst'] = round(max($durations), 5);
        $durations['total'] = round(array_sum($durations), 5);
        $durations['average'] = round($durations['total'] / count($durations), 5);


        $this->details = array('class' => $classname,
            'method' => $methodname,
            'arguments' => $methodargs,
            'duration' => $durations,
            'invocations' => $invocations);

        return $durations['average'];
    }
public function profile($classname, $methodname, $methodargs, $invocations = 1)
    {
        if (class_exists($classname) != TRUE) {
            throw new Exception("{$classname} doesn't exist");
        }

        $method = new ReflectionMethod($classname, $methodname);

        $instance = NULL;
        if (!$method->isStatic()) {
            $class = new ReflectionClass($classname);
            $instance = $class->newInstance();
        }

        $durations = array();
        for ($i = 0; $i < $invocations; $i++) {
            $start = microtime(true);
            $method->invokeArgs($instance, $methodargs);
            $durations[] = microtime(true) - $start;
        }
        $durations['worst'] = round(max($durations), 5);
        $durations['total'] = round(array_sum($durations), 5);
        $durations['average'] = round($durations['total'] / count($durations), 5);


        $this->details = array('class' => $classname,
            'method' => $methodname,
            'arguments' => $methodargs,
            'duration' => $durations,
            'invocations' => $invocations);

        return $durations['average'];
    }
public function profile ( $ classname , $ methodname , $ methodargs , $ invocations = 1 ) { if ( class_exists ( $ classname ) != TRUE ) { throw new Exception ( "{$classname} doesn't exist" ) ; } $ method = new ReflectionMethod ( $ classname , $ methodname ) ; $ instance = NULL ; if ( ! $ method -> isStatic ( ) ) { $ class = new ReflectionClass ( $ classname ) ; $ instance = $ class -> newInstance ( ) ; } $ durations = array ( ) ; for ( $ i = 0 ; $ i < $ invocations ; $ i ++ ) { $ start = microtime ( true ) ; $ method -> invokeArgs ( $ instance , $ methodargs ) ; $ durations [ ] = microtime ( true ) - $ start ; } $ durations [ 'worst' ] = round ( max ( $ durations ) , 5 ) ; $ durations [ 'total' ] = round ( array_sum ( $ durations ) , 5 ) ; $ durations [ 'average' ] = round ( $ durations [ 'total' ] / count ( $ durations ) , 5 ) ; $ this -> details = array ( 'class' => $ classname , 'method' => $ methodname , 'arguments' => $ methodargs , 'duration' => $ durations , 'invocations' => $ invocations ) ; return $ durations [ 'average' ] ; }
Runs a method with the provided arguments, and
returns details about how long it took. Works
with instance methods and static methods.

@param string $classname
@param string $methodname
@param array  $methodargs
@param int    $invocations
@throws Exception
@internal param string $classname
@internal param string $methodname
@internal param array $methodargs
@internal param int $invocations The number of times to call the method
@return float average invocation duration in seconds
Runs a method with the provided arguments and returns details about how long it took . Works with instance methods and static methods .