File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,9 @@ export async function fastestTest<T>(
2424async function runTracked < T > ( fn : ( ) => T ) : Promise < TimingResult < T > > {
2525 v8 . collectGarbage ( ) ;
2626 const gcTrack = new GarbageTrack ( ) ;
27- const { result : wrappedResult , trackId } = gcTrack . watch ( ( ) => runTimed ( fn ) ) ;
27+ const { result : wrappedResult , trackId } = await gcTrack . watch ( ( ) =>
28+ runTimed ( fn )
29+ ) ;
2830 const gcTime = await gcTrack . gcDuration ( trackId ) ;
2931 const { result, time } = wrappedResult ;
3032 gcTrack . destroy ( ) ;
Original file line number Diff line number Diff line change @@ -14,10 +14,13 @@ export class GarbageTrack {
1414 private periods : WatchPeriod [ ] = [ ] ;
1515
1616 /** look for gc events during the time this function is executing */
17- watch < T > ( fn : ( ) => T ) : { result : T ; trackId : number } {
17+ async watch < T > ( fn : ( ) => T ) : Promise < {
18+ result : Awaited < T > ;
19+ trackId : number ;
20+ } > {
1821 this . trackId ++ ;
1922 const start = performance . now ( ) ;
20- const result = fn ( ) ;
23+ const result = await fn ( ) ;
2124 const end = performance . now ( ) ;
2225 this . periods . push ( { trackId : this . trackId , start, end } ) ;
2326
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ export interface TimedResult<T> {
44}
55
66/** run a function, recording how long it takes */
7- export function runTimed < T > ( fn : ( ) => T ) : TimedResult < T > {
7+ export async function runTimed < T > ( fn : ( ) => T ) : Promise < TimedResult < T > > {
88 const start = performance . now ( ) ;
9- const result = fn ( ) ;
9+ const result = await fn ( ) ;
1010 const time = performance . now ( ) - start ;
1111 return { result, time } ;
1212}
You can’t perform that action at this time.
0 commit comments