DebugKit\DebugTimer::elapsedTime PHP Method

elapsedTime() public static method

Get the difference in time between the timer start and timer end.
public static elapsedTime ( string $name = 'default', integer $precision = 5 ) : float
$name string the name of the timer you want elapsed time for.
$precision integer the number of decimal places to return, defaults to 5.
return float number of seconds elapsed for timer name, 0 on missing key
    public static function elapsedTime($name = 'default', $precision = 5)
    {
        if (!isset(self::$_timers[$name]['start']) || !isset(self::$_timers[$name]['end'])) {
            return 0;
        }
        return round(self::$_timers[$name]['end'] - self::$_timers[$name]['start'], $precision);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Helper method for doing non-GET requests.
  *
  * @param string $method  HTTP method.
  * @param string $url     URL to request.
  * @param mixed  $data    The request body.
  * @param array  $options The options to use. Contains auth, proxy etc.
  *
  * @return \Cake\Network\Http\Response
  */
 protected function _doRequest($method, $url, $data, $options)
 {
     $request = $this->_createRequest($method, $url, $data, $options);
     $timerKey = 'debug_http.call.' . $url;
     if (Configure::read('debug')) {
         DebugTimer::start($timerKey, $method . ' ' . $url);
     }
     $response = $this->send($request, $options);
     if (Configure::read('debug')) {
         DebugTimer::stop($timerKey);
         ClientCallPanel::addCall($request, $response, DebugTimer::elapsedTime($timerKey));
     }
     return $response;
 }
All Usage Examples Of DebugKit\DebugTimer::elapsedTime