bench: Fix number formatting due to locale difference (#2655)
This commit is contained in:
parent
267c4ceab7
commit
721eb7a3be
|
@ -1,6 +1,6 @@
|
|||
/** Sync Markdown files in /bench based on the data from bench.json */
|
||||
|
||||
import { BenchData, BenchResult, Markdown } from "./utils";
|
||||
import { BenchData, BenchResult, Markdown, formatNumber } from "./utils";
|
||||
|
||||
(async () => {
|
||||
const bench = await BenchData.open();
|
||||
|
@ -41,7 +41,7 @@ import { BenchData, BenchResult, Markdown } from "./utils";
|
|||
// New key
|
||||
changeText = "N/A";
|
||||
} else {
|
||||
const delta = (newValue - oldValue).toLocaleString();
|
||||
const delta = formatNumber(newValue - oldValue);
|
||||
const percentChange = ((newValue / oldValue - 1) * 100).toFixed(2);
|
||||
|
||||
if (+percentChange > 0) {
|
||||
|
@ -51,10 +51,10 @@ import { BenchData, BenchResult, Markdown } from "./utils";
|
|||
}
|
||||
}
|
||||
|
||||
table.insert(name, newValue.toLocaleString(), changeText);
|
||||
table.insert(name, formatNumber(newValue), changeText);
|
||||
},
|
||||
noChangeCb: ({ name, value }) => {
|
||||
table.insert(name, value.toLocaleString(), +i === 0 ? "N/A" : "-");
|
||||
table.insert(name, formatNumber(value), +i === 0 ? "N/A" : "-");
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -527,11 +527,6 @@ export const getVersionFromArgs = () => {
|
|||
: (args[anchorVersionArgIndex + 1] as Version);
|
||||
};
|
||||
|
||||
/** Run `anchor test` command. */
|
||||
export const runAnchorTest = () => {
|
||||
return spawn("anchor", ["test", "--skip-lint"]);
|
||||
};
|
||||
|
||||
/** Spawn a blocking process. */
|
||||
export const spawn = (
|
||||
cmd: string,
|
||||
|
@ -549,3 +544,9 @@ export const spawn = (
|
|||
|
||||
return result;
|
||||
};
|
||||
|
||||
/** Run `anchor test` command. */
|
||||
export const runAnchorTest = () => spawn("anchor", ["test", "--skip-lint"]);
|
||||
|
||||
/** Format number with `en-US` locale. */
|
||||
export const formatNumber = (number: number) => number.toLocaleString("en-US");
|
||||
|
|
Loading…
Reference in New Issue