yii\httpclient\debug\HttpClientPanel::calculateTimings PHP Method

calculateTimings() public method

Calculates given request profile timings.
public calculateTimings ( ) : array
return array timings [token, category, timestamp, traces, nesting level, elapsed time]
    public function calculateTimings()
    {
        if ($this->_timings === null) {
            $this->_timings = Yii::getLogger()->calculateTimings(isset($this->data['messages']) ? $this->data['messages'] : []);
        }
        return $this->_timings;
    }

Usage Example

 /**
  * @param string $seq
  * @param string $tag
  * @param boolean $passthru whether to send response to the browser or render it as plain text
  * @return Response
  * @throws HttpException
  */
 public function run($seq, $tag, $passthru = false)
 {
     $this->controller->loadData($tag);
     $timings = $this->panel->calculateTimings();
     if (!isset($timings[$seq])) {
         throw new HttpException(404, 'Log message not found.');
     }
     $requestInfo = $timings[$seq]['info'];
     $httpRequest = $this->createRequestFromLog($requestInfo);
     $httpResponse = $httpRequest->send();
     $httpResponse->getHeaders()->get('content-type');
     $response = new Response(['format' => Response::FORMAT_RAW]);
     if ($passthru) {
         foreach ($httpResponse->getHeaders() as $name => $value) {
             $response->getHeaders()->set($name, $value);
         }
         $response->content = $httpResponse->content;
         return $response;
     }
     $response->getHeaders()->add('content-type', 'text/plain');
     $response->content = $httpResponse->toString();
     return $response;
 }