bench: Fix render

This commit is contained in:
2026-03-19 00:36:26 +01:00
parent 7b89ce077e
commit 7a15737107
3 changed files with 239 additions and 30 deletions

View File

@@ -87,7 +87,8 @@ if (entries.length === 0) {
process.exit(0);
}
// Sort chronologically, deduplicate by tag (latest wins)
// Sort chronologically, deduplicate by tag (latest wins),
// then order the resulting series by git tag.
entries.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
const byTag = new Map();
for (const e of entries) {
@@ -95,6 +96,22 @@ for (const e of entries) {
}
const deduped = [...byTag.values()];
function parseSemverTag(tag) {
const match = /^v?(\d+)\.(\d+)\.(\d+)$/.exec(tag);
return match ? match.slice(1).map(Number) : null;
}
deduped.sort((a, b) => {
const aTag = parseSemverTag(a.git_tag);
const bTag = parseSemverTag(b.git_tag);
if (aTag && bTag) {
return aTag[0] - bTag[0] || aTag[1] - bTag[1] || aTag[2] - bTag[2];
}
return a.git_tag.localeCompare(b.git_tag, undefined, { numeric: true });
});
// Determine which non-parrhesia servers are present
const baselineServerNames = ["strfry", "nostr-rs-relay"];
const presentBaselines = baselineServerNames.filter(srv =>
@@ -215,13 +232,22 @@ const fs = require("node:fs");
const [, , entryJson, readmePath] = process.argv;
const entry = JSON.parse(entryJson);
const { versions, ...servers } = entry;
const servers = entry.servers || {};
const pg = servers["parrhesia-pg"];
const mem = servers["parrhesia-memory"];
const strfry = servers["strfry"];
const nostrRs = servers["nostr-rs-relay"];
if (!pg || !mem) {
const present = Object.keys(servers).sort().join(", ") || "(none)";
console.error(
"Latest benchmark entry must include parrhesia-pg and parrhesia-memory. Present servers: " +
present
);
process.exit(1);
}
function toFixed(v, d = 2) {
return Number.isFinite(v) ? v.toFixed(d) : "n/a";
}