Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Timer.php

function Timer::stop

Same name in this branch
  1. 11.1.x vendor/phpunit/php-timer/src/Timer.php \SebastianBergmann\Timer\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).

1 call to Timer::stop()
Cron::invokeCronHandlers in core/lib/Drupal/Core/Cron.php
Invokes any cron handlers implementing hook_cron.

File

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

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];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal