public static function Timer::read

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.

2 calls to Timer::read()
TimerUnitTest::testTimer in drupal/core/tests/Drupal/Tests/Component/Utility/TimerUnitTest.php
Tests Timer::read() time accumulation accuracy across multiple restarts.
timer_read in drupal/core/includes/bootstrap.inc

File

drupal/core/lib/Drupal/Component/Utility/Timer.php, line 40
Contains \Drupal\Component\Utility\Timer.

Class

Timer
Provides helpers to use timers throughout a request.

Namespace

Drupal\Component\Utility

Code

public static 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'];
}