You are here

public static function Timer::stop in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Component/Utility/Timer.php \Drupal\Component\Utility\Timer::stop()

Stops the timer with the specified name.

Parameters

string $name: The name of the timer.

Return value

array 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).

2 calls to Timer::stop()
TimerTest::testTimer in core/tests/Drupal/Tests/Component/Utility/TimerTest.php
Tests Timer::read() time accumulation accuracy across multiple restarts.
ViewUI::renderPreview in core/modules/views_ui/src/ViewUI.php

File

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

Class

Timer
Provides helpers to use timers throughout a request.

Namespace

Drupal\Component\Utility

Code

public static function stop($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'])) {
      static::$timers[$name]['time'] += $diff;
    }
    else {
      static::$timers[$name]['time'] = $diff;
    }
    unset(static::$timers[$name]['start']);
  }
  return static::$timers[$name];
}