getElapsedTime example


  public function logFromEvent(StatementExecutionEndEvent $event): void {
    foreach (array_keys($this->queryLog) as $key) {
      $this->queryLog[$key][] = [
        'query' => $event->queryString,
        'args' => $event->args,
        'target' => $event->target,
        'caller' => $event->caller,
        'time' => $event->getElapsedTime(),
        'start' => $event->startTime,
      ];
    }
  }

  /** * Log a query to all active logging keys. * * @param \Drupal\Core\Database\StatementInterface $statement * The prepared statement object to log. * @param array $args * The arguments passed to the statement object. * @param float $time * The time the query took to execute as a float (in seconds with * microsecond precision). * @param float $start * The time the query started as a float (in seconds since the Unix epoch * with microsecond precision). * * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use * ::logFromEvent(). * * @see https://www.drupal.org/node/3328053 */
// If $returned is a string, then the controller output something,         // probably a view, instead of echoing it directly. Send it along         // so it can be used with the output.         $this->gatherOutput($cacheConfig$returned);

        if ($this->enableFilters) {
            $filters = Services::filters();
            $filters->setResponse($this->response);

            // After filter debug toolbar requires 'total_execution'.             $this->totalTime = $this->benchmark->getElapsedTime('total_execution');

            // Run "after" filters             $this->benchmark->start('after_filters');
            $response = $filters->run($uri, 'after');
            $this->benchmark->stop('after_filters');

            if ($response instanceof ResponseInterface) {
                $this->response = $response;
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.