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

Breadcrumb

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

function ResourceUsageFormatter::resourceUsageSinceStartOfRequest

Throws

TimeSinceStartOfRequestNotAvailableException

File

vendor/phpunit/php-timer/src/ResourceUsageFormatter.php, line 40

Class

ResourceUsageFormatter

Namespace

SebastianBergmann\Timer

Code

public function resourceUsageSinceStartOfRequest() : string {
    if (!isset($_SERVER['REQUEST_TIME_FLOAT'])) {
        throw new TimeSinceStartOfRequestNotAvailableException('Cannot determine time at which the request started because $_SERVER[\'REQUEST_TIME_FLOAT\'] is not available');
    }
    if (!is_float($_SERVER['REQUEST_TIME_FLOAT'])) {
        throw new TimeSinceStartOfRequestNotAvailableException('Cannot determine time at which the request started because $_SERVER[\'REQUEST_TIME_FLOAT\'] is not of type float');
    }
    return $this->resourceUsage(Duration::fromMicroseconds(1000000 * (microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'])));
}
RSS feed
Powered by Drupal