Skip to content

Commit 1031a28

Browse files
committed
fix #1904
1 parent 0830687 commit 1031a28

File tree

3 files changed

+163
-147
lines changed

3 files changed

+163
-147
lines changed

webdriver-ts-results/src/Common.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import { jStat } from "jstat";
22
import { formatEn } from "@/utils";
33
import { knownIssues } from "@/helpers/issues";
44

5+
// Formatter for memory results with 2 decimal places
6+
const formatMemory = new Intl.NumberFormat("en-US", {
7+
minimumFractionDigits: 2,
8+
maximumFractionDigits: 2,
9+
useGrouping: true,
10+
});
11+
512
export enum StatisticResult {
613
SLOWER,
714
UNDECIDED,
@@ -41,6 +48,14 @@ export enum BenchmarkType {
4148
SIZE = 5,
4249
}
4350

51+
// Map of benchmark types to their corresponding formatters
52+
const benchmarkFormatters = new Map<BenchmarkType, Intl.NumberFormat>([
53+
[BenchmarkType.CPU, formatEn],
54+
[BenchmarkType.MEM, formatMemory],
55+
[BenchmarkType.STARTUP, formatEn],
56+
[BenchmarkType.SIZE, formatEn],
57+
]);
58+
4459
const benchmarkTypes = [BenchmarkType.CPU, BenchmarkType.MEM, BenchmarkType.STARTUP, BenchmarkType.SIZE];
4560

4661
export interface Benchmark {
@@ -463,7 +478,8 @@ export class ResultTableData {
463478
const confidenceInterval =
464479
(1.959964 * (resultValues.standardDeviation || 0)) / Math.sqrt(resultValues.values.length);
465480
const confidenceIntervalStr = benchmark.type === BenchmarkType.CPU ? confidenceInterval.toFixed(1) : null;
466-
const formattedValue = formatEn.format(value);
481+
const formatter = benchmarkFormatters.get(benchmark.type) || formatEn;
482+
const formattedValue = formatter.format(value);
467483

468484
if (!this.compareWith || benchmark.type !== BenchmarkType.CPU) {
469485
return new TableResultValueEntry(

0 commit comments

Comments
 (0)