function BenchmarkCommand::generateYaml

Parameters

$gitHash:

$runs:

$url:

\Drupal\webprofiler\Command\BenchmarkData $avg:

\Drupal\webprofiler\Command\BenchmarkData $median:

\Drupal\webprofiler\Command\BenchmarkData $percentile95:

Return value

string

1 call to BenchmarkCommand::generateYaml()
BenchmarkCommand::execute in webprofiler/src/Command/BenchmarkCommand.php

File

webprofiler/src/Command/BenchmarkCommand.php, line 281

Class

BenchmarkCommand
Class BenchmarkCommand

Namespace

Drupal\webprofiler\Command

Code

private function generateYaml($gitHash, $runs, $url, BenchmarkData $avg, BenchmarkData $median, BenchmarkData $percentile95) {
    $yaml = Yaml::dump([
        'date' => date($this->trans('commands.webprofiler.list.rows.time'), time()),
        'git_commit' => $gitHash,
        'number_of_runs' => $runs,
        'url' => $url,
        'results' => [
            'average' => [
                'time' => sprintf('%.0f ms', $avg->getTime()),
                'memory' => sprintf('%.1f MB', $avg->getMemory() / 1024 / 1024),
            ],
            'median' => [
                'time' => sprintf('%.0f ms', $median->getTime()),
                'memory' => sprintf('%.1f MB', $median->getMemory() / 1024 / 1024),
            ],
            '95_percentile' => [
                'time' => sprintf('%.0f ms', $percentile95->getTime()),
                'memory' => sprintf('%.1f MB', $percentile95->getMemory() / 1024 / 1024),
            ],
        ],
    ]);
    return $yaml;
}