@@ -22,7 +22,7 @@ import {
22
22
type JsonTestbed ,
23
23
type JsonThreshold ,
24
24
} from "../../../../../types/bencher" ;
25
- import { dateTimeMillis } from "../../../../../util/convert" ;
25
+ import { dateTimeMillis , prettyPrintFloat } from "../../../../../util/convert" ;
26
26
import { BACK_PARAM , encodePath } from "../../../../../util/url" ;
27
27
28
28
export interface Props {
@@ -489,10 +489,10 @@ const ValueCell = (props: {
489
489
490
490
return (
491
491
< >
492
- { formatNumber ( props . value ) }
492
+ { prettyPrintFloat ( props . value ) }
493
493
< Show when = { percent !== null } >
494
494
< br /> ({ percent > 0.0 ? "+" : "" }
495
- { formatNumber ( percent ) } %)
495
+ { prettyPrintFloat ( percent ) } %)
496
496
</ Show >
497
497
</ >
498
498
) ;
@@ -562,8 +562,8 @@ const LimitCell = (props: {
562
562
percent : number ;
563
563
} ) => (
564
564
< >
565
- { formatNumber ( props . limit ) }
566
- < br /> ({ formatNumber ( props . percent ) } %)
565
+ { prettyPrintFloat ( props . limit ) }
566
+ < br /> ({ prettyPrintFloat ( props . percent ) } %)
567
567
</ >
568
568
) ;
569
569
@@ -752,48 +752,4 @@ const union = (lhs: BoundaryLimits, rhs: BoundaryLimits): BoundaryLimits => {
752
752
} ;
753
753
} ;
754
754
755
- // biome-ignore lint/style/useEnumInitializers: variants
756
- enum Position {
757
- Whole ,
758
- Point ,
759
- Decimal ,
760
- }
761
-
762
- const formatNumber = ( number : number ) : string => {
763
- let numberStr = "" ;
764
- let position = Position . Decimal ;
765
- const formattedNumber = Math . abs ( number ) . toFixed ( 2 ) ;
766
- const isNegative = number < 0 ;
767
-
768
- for ( let i = formattedNumber . length - 1 ; i >= 0 ; i -- ) {
769
- const c = formattedNumber [ i ] ;
770
- switch ( position ) {
771
- case Position . Whole :
772
- if (
773
- ( formattedNumber . length - 1 - i ) % 3 === 0 &&
774
- i !== formattedNumber . length - 1
775
- ) {
776
- numberStr = `,${ numberStr } ` ;
777
- }
778
- position = Position . Whole ;
779
- break ;
780
- case Position . Point :
781
- position = Position . Whole ;
782
- break ;
783
- case Position . Decimal :
784
- if ( c === "." ) {
785
- position = Position . Point ;
786
- }
787
- break ;
788
- }
789
- numberStr = c + numberStr ;
790
- }
791
-
792
- if ( isNegative ) {
793
- numberStr = `-${ numberStr } ` ;
794
- }
795
-
796
- return numberStr ;
797
- } ;
798
-
799
755
export default ReportCard ;
0 commit comments