-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
table.mjs
52 lines (43 loc) · 1.56 KB
/
table.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import fs from 'node:fs'
import { markdownTable } from 'markdown-table'
async function readData() {
const data = {};
const dir = "./target/criterion";
const groups = await fs.promises.readdir(dir);
for (const group of groups) {
data[group] ||= {};
const benches = await fs.promises.readdir(`${dir}/${group}`);
for (const bench of benches) {
data[group][bench] ||= {};
const measurements = await fs.promises.readdir(`${dir}/${group}/${bench}`);
for (const measurement of measurements) {
const json = await import(`${dir}/${group}/${bench}/${measurement}/new/estimates.json`, { assert: { type: "json" } });
const duration_ms = json.default.mean.point_estimate / 1_000_000;
data[group][bench][measurement] ||= { duration_ms };
}
}
}
return data
}
async function main() {
const data = await readData();
const groups = Object.keys(data);
const columns = Object.keys(data[groups[0]]);
const rows = Object.keys(data[groups[0]][columns[0]]);
for (const group of groups) {
console.log(`### ${group}`);
console.log()
const table = [["", ...columns]];
for (const row of rows) {
const column_numbers = columns.map((column) => data[group][column][row].duration_ms);
const minimum = Math.min(...column_numbers);
const column_values = column_numbers.map((number) => {
return `\`${number.toFixed(1)} ms\` (${(number / minimum).toFixed(2)}x)`
});
table.push([row, ...column_values]);
}
console.log(markdownTable(table));
console.log()
}
}
main()