Skip to content

Commit 18302e3

Browse files
chore: Localize op/sec in text reporter (#146)
* chore: Localize op/sec in text reporter * fixup! chore: Localize op/sec in text reporter --------- Co-authored-by: RafaelGSS <rafael.nunu@hotmail.com>
1 parent 814e88e commit 18302e3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/reporter/text.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function toText(results, options = {}) {
2121
text += " x ";
2222

2323
if (result.opsSec !== undefined) {
24-
text += styleText(["blue", "bold"], `${result.opsSec} ops/sec`);
24+
text += styleText(["blue", "bold"], `${localize(result.opsSec)} ops/sec`);
2525
} else if (result.totalTime !== undefined) {
2626
text += styleText(["blue", "bold"], `${result.timeFormatted} total time`);
2727
}
@@ -72,6 +72,17 @@ function toText(results, options = {}) {
7272
return text;
7373
}
7474

75+
const numberFormat = new Intl.NumberFormat(
76+
process.env.BENCH_NODE_LOCALE_ID || "en-US",
77+
{
78+
style: "decimal",
79+
useGrouping: true,
80+
},
81+
);
82+
function localize(number) {
83+
return numberFormat.format(number);
84+
}
85+
7586
module.exports = {
7687
textReport,
7788
toText,

0 commit comments

Comments
 (0)