@@ -2,6 +2,13 @@ import { jStat } from "jstat";
22import { formatEn } from "@/utils" ;
33import { 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+
512export 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+
4459const benchmarkTypes = [ BenchmarkType . CPU , BenchmarkType . MEM , BenchmarkType . STARTUP , BenchmarkType . SIZE ] ;
4560
4661export 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