Skip to content

Commit 7e68155

Browse files
chore: run with naive implementation before refactor
1 parent e6f1823 commit 7e68155

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/tinybench-plugin/src/walltime.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import {
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";
1112
import { getTaskUri } from "./uri";
1213

1314
export 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) {

0 commit comments

Comments
 (0)