Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: output benchmark results to tmp/benchmark #403

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ export function run({
await client.flushdb();
}),
save({
file: `${driver}-bench`,
file: driver,
details: true,
folder: join(dirname(dirname(new URL(import.meta.url).pathname)), "tmp"),
folder: join(
dirname(dirname(new URL(import.meta.url).pathname)),
"tmp/benchmark",
),
}),
);
}
17 changes: 10 additions & 7 deletions tools/format-benchmark-results.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { join } from "node:path";

function formatResultsAsMarkdown({ name, results }) {
const detailKeys = ["min", "max", "mean", "median"];
const header = ["name", "ops", "margin", ...detailKeys, "samples"];
Expand Down Expand Up @@ -25,11 +27,12 @@ function makeTableRow(columns) {
return `|${columns.join("|")}|`;
}

const tmpDir = new URL("../tmp", import.meta.url).pathname;
for (const driver of ["deno-redis", "ioredis"]) {
console.log(
formatResultsAsMarkdown(
JSON.parse(await Deno.readTextFile(`${tmpDir}/${driver}-bench.json`)),
),
);
const resultsDir = new URL("../tmp/benchmark", import.meta.url);
const paths = Array.from(Deno.readDirSync(resultsDir)).map((x) =>
join(resultsDir.pathname, x.name)
).sort();
for (const path of paths) {
const results = JSON.parse(await Deno.readTextFile(path));
const markdown = formatResultsAsMarkdown(results);
console.log(markdown);
}