From d24465ba20b6e32f67c326629c4c3f9dcda2267d Mon Sep 17 00:00:00 2001 From: Arthur Pastel Date: Wed, 21 Jun 2023 14:54:30 +0200 Subject: [PATCH] fixup! feat: add a root frame for the callgraph generation --- packages/tinybench-plugin/src/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/tinybench-plugin/src/index.ts b/packages/tinybench-plugin/src/index.ts index 5aae984..422e498 100644 --- a/packages/tinybench-plugin/src/index.ts +++ b/packages/tinybench-plugin/src/index.ts @@ -24,12 +24,14 @@ export function withCodSpeed(bench: Bench): Bench { console.log(`[CodSpeed] running with @codspeed/tinybench v${__VERSION__}`); for (const task of bench.tasks) { const uri = callingFile + "::" + task.name; - await (async function __codspeed_root_frame__() { - await optimizeFunction(task.fn); - measurement.startInstrumentation(); + // eslint-disable-next-line no-inner-declarations + async function __codspeed_root_frame__() { await task.fn(); - measurement.stopInstrumentation(uri); - })(); + } + await optimizeFunction(__codspeed_root_frame__); + measurement.startInstrumentation(); + await __codspeed_root_frame__(); + measurement.stopInstrumentation(uri); console.log(` ✔ Measured ${uri}`); } console.log(`[CodSpeed] Done running ${bench.tasks.length} benches.`);