-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbenchmark.js
33 lines (28 loc) · 845 Bytes
/
benchmark.js
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
"use strict";
const fs = require("fs");
const { fork } = require("child_process");
const args = require("minimist")(process.argv.slice(2), {
string: ["data", "tests"],
default: {
data: "small.json",
chunkSize: 16 * 1024
}
});
const filter = args.tests ? args.tests.split(",") : [];
const tests = fs.readdirSync("./tests").filter(t => (filter.length ? filter.some(s => t.startsWith(`${s}.`)) : true)).sort((a, b) => a.split(".")[0] - b.split(".")[0]);
try {
fs.readFileSync(`./data/${args.data}`);
} catch(e) {
throw new Error(`test file ${args.data} not found, aborting...`);
}
console.log(`Benchmarking ${args.data}`);
(async () => {
for(const test of tests) {
await new Promise(r => {
const c = fork(`./tests/${test}`, [JSON.stringify(args)]);
c.on("exit", () => {
setTimeout(() => r(), 1000);
});
});
}
})();