Timer::read

static public Timer::read($name)

Reads the current timer value without stopping the timer.

Parameters

string $name: The name of the timer.

Return value

int The current timer value in ms.

File

core/lib/Drupal/Component/Utility/Timer.php, line 37

Class

Timer
Provides helpers to use timers throughout a request.

Namespace

Drupal\Component\Utility

Code

static public function read($name) {
  if (isset(static::$timers[$name]['start'])) {
    $stop = microtime(TRUE);
    $diff = round(($stop - static::$timers[$name]['start']) * 1000, 2);

    if (isset(static::$timers[$name]['time'])) {
      $diff += static::$timers[$name]['time'];
    }
    return $diff;
  }
  return static::$timers[$name]['time'];
}
doc_Drupal
2016-10-29 09:48:28
Comments
Leave a Comment

Please login to continue.