@c4312/matcha
Version:
A caffeine driven, simple command line for benchmarking
36 lines • 989 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const os_1 = require("os");
exports.jsonFactory = {
description: 'Outputs stats as raw JSON',
start: () => new JsonReporter(process.stdout),
};
class JsonReporter {
constructor(out) {
this.out = out;
this.printed = 0;
}
onStartCycle() {
// no-op
}
onFinishCycle(benchmark) {
if (benchmark.error) {
throw benchmark.error;
}
this.out.write((this.printed++ > 0 ? ',' : '[') +
os_1.EOL +
' ' +
JSON.stringify({
name: benchmark.name,
hz: benchmark.hz,
mean: benchmark.stats.mean,
deviation: benchmark.stats.deviation,
count: benchmark.count,
}));
}
onComplete() {
this.out.write(`${os_1.EOL}]${os_1.EOL}`);
}
}
exports.JsonReporter = JsonReporter;
//# sourceMappingURL=json.js.map