mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Polish benchmark reporting
This commit is contained in:
@@ -746,8 +746,30 @@ jobs:
|
||||
docker run --rm -i -v "$PWD:/scripts" -w /scripts ${{ env.IMAGE }}:after php <<'PHP' > benchmark-comment.txt
|
||||
<?php
|
||||
|
||||
$before = json_decode(file_get_contents('benchmark-before-summary.json'), true);
|
||||
$after = json_decode(file_get_contents('benchmark-after-summary.json'), true);
|
||||
function read_summary(string $path): array
|
||||
{
|
||||
if (!is_file($path)) {
|
||||
fwrite(STDERR, "Missing benchmark summary: {$path}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
$summary = json_decode(file_get_contents($path), true, 512, JSON_THROW_ON_ERROR);
|
||||
} catch (JsonException $error) {
|
||||
fwrite(STDERR, "Invalid benchmark summary {$path}: {$error->getMessage()}\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!is_array($summary)) {
|
||||
fwrite(STDERR, "Invalid benchmark summary {$path}: expected JSON object\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return $summary;
|
||||
}
|
||||
|
||||
$before = read_summary('benchmark-before-summary.json');
|
||||
$after = read_summary('benchmark-after-summary.json');
|
||||
|
||||
function metric_value(?array $data, string $metric, string $stat): mixed
|
||||
{
|
||||
|
||||
@@ -290,7 +290,12 @@ final class HttpBenchmark
|
||||
$context = $this->setup();
|
||||
|
||||
for ($i = 0; $i < $this->iterations * $this->vus; $i++) {
|
||||
$this->curatedFlows($context);
|
||||
try {
|
||||
$this->curatedFlows($context);
|
||||
} catch (Throwable $error) {
|
||||
$exitCode = 1;
|
||||
fwrite(STDERR, 'Iteration ' . ($i + 1) . ' failed: ' . $error->getMessage() . PHP_EOL);
|
||||
}
|
||||
}
|
||||
} catch (Throwable $error) {
|
||||
$exitCode = 1;
|
||||
@@ -1216,7 +1221,7 @@ final class HttpBenchmark
|
||||
'',
|
||||
];
|
||||
|
||||
return implode(PHP_EOL, array_filter($lines, fn (string $line): bool => $line !== '')) . PHP_EOL;
|
||||
return implode(PHP_EOL, $lines) . PHP_EOL;
|
||||
}
|
||||
|
||||
private function comparisonTable(?array $before, array $after): string
|
||||
|
||||
Reference in New Issue
Block a user