@@ -23,6 +23,7 @@ import { TraceModel, buildActionTree } from '../../utils/isomorphic/trace/traceM
2323import { TraceLoader } from '../../utils/isomorphic/trace/traceLoader' ;
2424import { renderTitleForCall } from '../../utils/isomorphic/protocolFormatter' ;
2525import { asLocatorDescription } from '../../utils/isomorphic/locatorGenerators' ;
26+ import { msToString , bytesToString } from '../../utils/isomorphic/formatUtils' ;
2627import { ZipTraceLoaderBackend } from './traceParser' ;
2728
2829import type { ActionTraceEventInContext } from '@isomorphic/trace/traceModel' ;
@@ -149,43 +150,6 @@ export async function loadTraceModel(traceFile: string): Promise<TraceModel> {
149150 return ( await loadTrace ( traceFile ) ) . model ;
150151}
151152
152- function msToString ( ms : number ) : string {
153- if ( ms < 0 || ! isFinite ( ms ) )
154- return '-' ;
155- if ( ms === 0 )
156- return '0' ;
157- if ( ms < 1000 )
158- return ms . toFixed ( 0 ) + 'ms' ;
159- const seconds = ms / 1000 ;
160- if ( seconds < 60 )
161- return seconds . toFixed ( 1 ) + 's' ;
162- const minutes = seconds / 60 ;
163- if ( minutes < 60 )
164- return minutes . toFixed ( 1 ) + 'm' ;
165- const hours = minutes / 60 ;
166- if ( hours < 24 )
167- return hours . toFixed ( 1 ) + 'h' ;
168- const days = hours / 24 ;
169- return days . toFixed ( 1 ) + 'd' ;
170- }
171-
172- function bytesToString ( bytes : number ) : string {
173- if ( bytes < 0 || ! isFinite ( bytes ) )
174- return '-' ;
175- if ( bytes === 0 )
176- return '0' ;
177- if ( bytes < 1000 )
178- return bytes . toFixed ( 0 ) ;
179- const kb = bytes / 1024 ;
180- if ( kb < 1000 )
181- return kb . toFixed ( 1 ) + 'K' ;
182- const mb = kb / 1024 ;
183- if ( mb < 1000 )
184- return mb . toFixed ( 1 ) + 'M' ;
185- const gb = mb / 1024 ;
186- return gb . toFixed ( 1 ) + 'G' ;
187- }
188-
189153function formatTimestamp ( ms : number , base : number ) : string {
190154 const relative = ms - base ;
191155 if ( relative < 0 )
0 commit comments