diff --git a/tests/bench/scripts/sync-markdown.ts b/tests/bench/scripts/sync-markdown.ts index 2ced9e47e9..1baa05acc1 100644 --- a/tests/bench/scripts/sync-markdown.ts +++ b/tests/bench/scripts/sync-markdown.ts @@ -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" : "-"); }, }); diff --git a/tests/bench/scripts/utils.ts b/tests/bench/scripts/utils.ts index 7b1b1e7a69..ec52c297a4 100644 --- a/tests/bench/scripts/utils.ts +++ b/tests/bench/scripts/utils.ts @@ -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");