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

Breadcrumb

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

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()
Cron::invokeCronHandlers in core/lib/Drupal/Core/Cron.php
Invokes any cron handlers implementing hook_cron.
_batch_process in core/includes/batch.inc
Processes sets in a batch.

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

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

API Navigation

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