You are here

protected function DebugMessageFormatterPluginBase::getTimeStatsInSeconds in Apigee Edge 8

Utility function that collects and formats times from transfer statistic.

Parameters

\GuzzleHttp\TransferStats $stats: Transfer statistic.

int $precision: Precision of rounding applied on times.

Return value

array Array of measured times.

2 calls to DebugMessageFormatterPluginBase::getTimeStatsInSeconds()
DebugMessageFormatterPluginBase::formatStats in modules/apigee_edge_debug/src/Plugin/DebugMessageFormatter/DebugMessageFormatterPluginBase.php
Formats stats object.
FullHttpMessageFormatter::formatStats in modules/apigee_edge_debug/src/Plugin/DebugMessageFormatter/FullHttpMessageFormatter.php
Formats stats object.

File

modules/apigee_edge_debug/src/Plugin/DebugMessageFormatter/DebugMessageFormatterPluginBase.php, line 179

Class

DebugMessageFormatterPluginBase
Defines a base class for debug message formatter plugins.

Namespace

Drupal\apigee_edge_debug\Plugin\DebugMessageFormatter

Code

protected function getTimeStatsInSeconds(TransferStats $stats, int $precision = 3) : array {
  $time_stats = array_filter($stats
    ->getHandlerStats(), function ($key) {
    return preg_match('/_time$/', $key);
  }, ARRAY_FILTER_USE_KEY);
  return array_map(function ($stat) use ($precision) {
    return round($stat, $precision) . 's';
  }, $time_stats);
}