-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathcli.js
40 lines (34 loc) · 1.24 KB
/
cli.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
34
35
36
37
38
39
40
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
const align = require("string-align");
const gmean = require("compute-gmean");
const packageJson = require("../package.json");
const suite = require("./suite");
console.log(`Running Web Tooling Benchmark v${packageJson.version}…`);
console.log("-------------------------------------");
suite.on("error", event => {
const benchmark = event.target;
const name = benchmark.name;
const error = benchmark.error;
console.log(`Encountered error running benchmark ${name}, aborting…`);
console.log(error.stack);
suite.abort();
});
suite.on("cycle", event => {
if (suite.aborted) return;
const benchmark = event.target;
const name = benchmark.name;
const hz = benchmark.hz;
const stats = benchmark.stats;
console.log(
`${align(name, 14, "right")}: ${align(hz.toFixed(2), 5, "right")} runs/s`
);
});
suite.on("complete", event => {
if (suite.aborted) return;
const hz = gmean(suite.map(benchmark => benchmark.hz));
console.log("-------------------------------------");
console.log(`Geometric mean: ${align(hz.toFixed(2), 5, "right")} runs/s`);
});
suite.run();