File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
packages/tinybench-plugin/src Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 11import {
22 Benchmark ,
33 calculateQuantiles ,
4+ InstrumentHooks ,
45 mongoMeasurement ,
56 msToNs ,
67 msToS ,
78 writeWalltimeResults ,
89 type BenchmarkStats ,
910} from "@codspeed/core" ;
10- import { Bench , TaskResult } from "tinybench" ;
11+ import { Bench , Fn , TaskResult } from "tinybench" ;
1112import { getTaskUri } from "./uri" ;
1213
1314export function setupCodspeedWalltimeBench (
@@ -39,13 +40,24 @@ export function setupCodspeedWalltimeBench(
3940 for ( const task of bench . tasks ) {
4041 const uri = getTaskUri ( bench , task . name , rootCallingFile ) ;
4142
43+ const { fn } = task as unknown as { fn : Fn } ;
44+ // eslint-disable-next-line no-inner-declarations
45+ async function __codspeed_root_frame__ ( ) {
46+ await fn ( ) ;
47+ }
48+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49+ ( task as any ) . fn = __codspeed_root_frame__ ;
50+
4251 // run the warmup of the task right before its actual run
4352 if ( bench . opts . warmup ) {
4453 await task . warmup ( ) ;
4554 }
4655 await mongoMeasurement . start ( uri ) ;
56+ InstrumentHooks . startBenchmark ( ) ;
4757 const taskResult = await task . run ( ) ;
58+ InstrumentHooks . stopBenchmark ( ) ;
4859 await mongoMeasurement . stop ( uri ) ;
60+ InstrumentHooks . setExecutedBenchmark ( process . pid , uri ) ;
4961 results . push ( taskResult ) ;
5062
5163 if ( task . result ) {
You can’t perform that action at this time.
0 commit comments