public function end($name)
    {
        if(!$this->isEnabled()) return;

        $aggregate = 0;

        // if (empty($name))
        //     throw new BenchmarkException("Empty timer name!");
        //
        // if (array_key_exists($name, $this->timers) && !empty($this->timers[$name]['end'])) {
        //     $inc = 1;
        //     while (array_key_exists($name.'-'.$inc, $this->timers) && !empty($this->timers[$name]['end'])) {
        //         $inc++;
        //     }
        //     $name = $name.'-'.$inc;
        // }

        $oldTime = $this->firstTime;
        if (array_key_exists($name, $this->timers))
            $oldTime = $this->timers[$name]['time'];
            //throw new BenchmarkException("Timer name '{$name}' not found! Please call start(...) first!");

        // $this->timers[$name]['end'] = $this->getTime();
        $n = $this->getTime();

        // $this->timers[$name]['time'] = ($this->timers[$name]['end'] - $this->timers[$name]['start'])*1000;
        $time = ($n - $oldTime)*1000;
        if ($this->globalMode)
            // $this->timers[$name]['aggregate'] = ($n - $this->firstTime)*1000;
            $aggregate = ($n - $this->firstTime)*1000;

        // $this->Logger->debug("Timer [{$name}]: {$this->timers[$name]['time']}ms, aggregate {$this->timers[$name]['aggregate']}ms");
        $this->Logger->debug("Timer [{$name}]: {$time}ms".($this->globalMode?", aggregate {$aggregate}ms":""));
        unset($this->timers[$name]);

        return $time;
    }
public function end($name)
    {
        if(!$this->isEnabled()) return;

        $aggregate = 0;

        // if (empty($name))
        //     throw new BenchmarkException("Empty timer name!");
        //
        // if (array_key_exists($name, $this->timers) && !empty($this->timers[$name]['end'])) {
        //     $inc = 1;
        //     while (array_key_exists($name.'-'.$inc, $this->timers) && !empty($this->timers[$name]['end'])) {
        //         $inc++;
        //     }
        //     $name = $name.'-'.$inc;
        // }

        $oldTime = $this->firstTime;
        if (array_key_exists($name, $this->timers))
            $oldTime = $this->timers[$name]['time'];
            //throw new BenchmarkException("Timer name '{$name}' not found! Please call start(...) first!");

        // $this->timers[$name]['end'] = $this->getTime();
        $n = $this->getTime();

        // $this->timers[$name]['time'] = ($this->timers[$name]['end'] - $this->timers[$name]['start'])*1000;
        $time = ($n - $oldTime)*1000;
        if ($this->globalMode)
            // $this->timers[$name]['aggregate'] = ($n - $this->firstTime)*1000;
            $aggregate = ($n - $this->firstTime)*1000;

        // $this->Logger->debug("Timer [{$name}]: {$this->timers[$name]['time']}ms, aggregate {$this->timers[$name]['aggregate']}ms");
        $this->Logger->debug("Timer [{$name}]: {$time}ms".($this->globalMode?", aggregate {$aggregate}ms":""));
        unset($this->timers[$name]);

        return $time;
    }
public function end ( $ name ) { if ( ! $ this -> isEnabled ( ) ) return ; $ aggregate = 0 ; // if (empty($name)) //     throw new BenchmarkException("Empty timer name!"); // // if (array_key_exists($name, $this->timers) && !empty($this->timers[$name]['end'])) { //     $inc = 1; //     while (array_key_exists($name.'-'.$inc, $this->timers) && !empty($this->timers[$name]['end'])) { //         $inc++; //     } //     $name = $name.'-'.$inc; // } $ oldTime = $ this -> firstTime ; if ( array_key_exists ( $ name , $ this -> timers ) ) $ oldTime = $ this -> timers [ $ name ] [ 'time' ] ; //throw new BenchmarkException("Timer name '{$name}' not found! Please call start(...) first!"); // $this->timers[$name]['end'] = $this->getTime(); $ n = $ this -> getTime ( ) ; // $this->timers[$name]['time'] = ($this->timers[$name]['end'] - $this->timers[$name]['start'])*1000; $ time = ( $ n - $ oldTime ) * 1000 ; if ( $ this -> globalMode ) // $this->timers[$name]['aggregate'] = ($n - $this->firstTime)*1000; $ aggregate = ( $ n - $ this -> firstTime ) * 1000 ; // $this->Logger->debug("Timer [{$name}]: {$this->timers[$name]['time']}ms, aggregate {$this->timers[$name]['aggregate']}ms"); $ this -> Logger -> debug ( "Timer [{$name}]: {$time}ms" . ( $ this -> globalMode ? ", aggregate {$aggregate}ms" : "" ) ) ; unset ( $ this -> timers [ $ name ] ) ; return $ time ; }
Ends and stores the elapsed time for the timer with the given name

If is in aggregation mode, also stores the aggregate time for this timer.
This is useful for tracing a request and noticing large lapses in
processing that may not have a timer implemented.

If a timer by the same name has already been stored, this function will
auto-increment the {@link $name} with a numeric digit, ex. 'timer-2',
before attempting to store the end time.

@param string $name Name of timer

@return int Elapsed time in milliseconds
@throws BenchmarkException When ending a timer that was not started
Ends and stores the elapsed time for the timer with the given name