enhance benchmark output with thousands separators (#13512)
This commit is contained in:
parent
90d5eb7f2f
commit
e6068cd9a5
@ -1,13 +1,17 @@
|
|||||||
export function report(event) {
|
export function report(event) {
|
||||||
const bench = event.target;
|
const bench = event.target;
|
||||||
const factor = bench.hz < 100 ? 100 : 1;
|
|
||||||
const timeMs = bench.stats.mean * 1000;
|
const timeMs = bench.stats.mean * 1000;
|
||||||
const time =
|
const time =
|
||||||
timeMs < 10
|
timeMs < 10
|
||||||
? `${Math.round(timeMs * 1000) / 1000}ms`
|
? `${Math.round(timeMs * 1000) / 1000}ms`
|
||||||
: `${Math.round(timeMs)}ms`;
|
: `${Math.round(timeMs)}ms`;
|
||||||
const msg = `${bench.name}: ${
|
const msg = `${bench.name}: ${formatNumber(bench.hz)} ops/sec ±${
|
||||||
Math.round(bench.hz * factor) / factor
|
Math.round(bench.stats.rme * 100) / 100
|
||||||
} ops/sec ±${Math.round(bench.stats.rme * 100) / 100}% (${time})`;
|
}% (${time})`;
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatNumber(x) {
|
||||||
|
if (x < 100) return `${Math.round(x * 100) / 100}`;
|
||||||
|
return `${Math.round(x)}`.replace(/\d(?=(?:\d{3})+$)/g, "$&_");
|
||||||
|
}
|
||||||
|
|||||||
@ -1,13 +1,17 @@
|
|||||||
export function report(event) {
|
export function report(event) {
|
||||||
const bench = event.target;
|
const bench = event.target;
|
||||||
const factor = bench.hz < 100 ? 100 : 1;
|
|
||||||
const timeMs = bench.stats.mean * 1000;
|
const timeMs = bench.stats.mean * 1000;
|
||||||
const time =
|
const time =
|
||||||
timeMs < 10
|
timeMs < 10
|
||||||
? `${Math.round(timeMs * 1000) / 1000}ms`
|
? `${Math.round(timeMs * 1000) / 1000}ms`
|
||||||
: `${Math.round(timeMs)}ms`;
|
: `${Math.round(timeMs)}ms`;
|
||||||
const msg = `${bench.name}: ${
|
const msg = `${bench.name}: ${formatNumber(bench.hz)} ops/sec ±${
|
||||||
Math.round(bench.hz * factor) / factor
|
Math.round(bench.stats.rme * 100) / 100
|
||||||
} ops/sec ±${Math.round(bench.stats.rme * 100) / 100}% (${time})`;
|
}% (${time})`;
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatNumber(x) {
|
||||||
|
if (x < 100) return `${Math.round(x * 100) / 100}`;
|
||||||
|
return `${Math.round(x)}`.replace(/\d(?=(?:\d{3})+$)/g, "$&_");
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user