function timer_stop

7.x timer_stop($name)
5.x timer_stop($name)
6.x timer_stop($name)

Stops the timer with the specified name.


$name: The name of the timer.

Return value

A timer array. The array contains the number of times the timer has been started and stopped (count) and the accumulated timer value in ms (time).

1 call to timer_stop()
BootstrapTimerTestCase::testTimer in drupal/modules/simpletest/tests/bootstrap.test
Test timer_read() to ensure it properly accumulates time when the timer started and stopped multiple times.


drupal/includes/, line 510
Functions that need to be loaded on every Drupal request.


function timer_stop($name) {
  global $timers;

  if (isset($timers[$name]['start'])) {
    $stop = microtime(TRUE);
    $diff = round(($stop - $timers[$name]['start']) * 1000, 2);
    if (isset($timers[$name]['time'])) {
      $timers[$name]['time'] += $diff;
    else {
      $timers[$name]['time'] = $diff;

  return $timers[$name];