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

Breadcrumb

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

class Timer

Same name in this branch
  1. 11.1.x core/lib/Drupal/Component/Utility/Timer.php \Drupal\Component\Utility\Timer

Hierarchy

  • class \SebastianBergmann\Timer\Timer

Expanded class hierarchy of Timer

4 files declare their use of Timer
Application.php in vendor/phpunit/phpunit/src/TextUI/Application.php
CodeCoverage.php in vendor/phpunit/phpunit/src/Runner/CodeCoverage.php
ExcludeList.php in vendor/phpunit/phpunit/src/Util/ExcludeList.php
WarmCodeCoverageCacheCommand.php in vendor/phpunit/phpunit/src/TextUI/Command/Commands/WarmCodeCoverageCacheCommand.php
1 string reference to 'Timer'
badge.component.yml in core/profiles/demo_umami/themes/umami/components/badge/badge.component.yml
core/profiles/demo_umami/themes/umami/components/badge/badge.component.yml

File

vendor/phpunit/php-timer/src/Timer.php, line 15

Namespace

SebastianBergmann\Timer
View source
final class Timer {
    
    /**
     * @psalm-var list<float>
     */
    private array $startTimes = [];
    public function start() : void {
        $this->startTimes[] = (double) hrtime(true);
    }
    
    /**
     * @throws NoActiveTimerException
     */
    public function stop() : Duration {
        if (empty($this->startTimes)) {
            throw new NoActiveTimerException('Timer::start() has to be called before Timer::stop()');
        }
        return Duration::fromNanoseconds((double) hrtime(true) - array_pop($this->startTimes));
    }

}

Members

Title Sort descending Modifiers Object type Summary
Timer::$startTimes private property @psalm-var list&lt;float&gt;
Timer::start public function
Timer::stop public function
RSS feed
Powered by Drupal