Skip to content

Commit 13842a0

Browse files
committed
feat(vitest-runner): add mongo-measurement integration
1 parent 76d4d4f commit 13842a0

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/core/moon.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ tasks:
55
- generated/openapi
66
build:
77
deps:
8-
- "build-native-addon"
8+
- build-native-addon
9+
- build-tracer-client
910

1011
build-native-addon:
1112
command: prebuildify --napi --strip

packages/vitest-plugin/src/runner.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
getGitDir,
33
logDebug,
44
Measurement,
5+
mongoMeasurement,
56
optimizeFunction,
67
setupCore,
78
teardownCore,
@@ -48,12 +49,14 @@ async function runBenchmarkSuite(suite: Suite, parentSuiteName?: string) {
4849
const fn = getBenchFn(benchmark);
4950

5051
await optimizeFunction(fn);
52+
await mongoMeasurement.start(uri);
5153
await (async function __codspeed_root_frame__() {
5254
Measurement.startInstrumentation();
5355
// @ts-expect-error we do not need to bind the function to an instance of tinybench's Bench
5456
await fn();
5557
Measurement.stopInstrumentation(uri);
5658
})();
59+
await mongoMeasurement.stop(uri);
5760

5861
logCodSpeed(`${uri} done`);
5962
}
@@ -82,7 +85,10 @@ class CodSpeedRunner extends NodeBenchmarkRunner {
8285
await runBenchmarkSuite(suite);
8386
logCodSpeed(`running suite ${suite.name} done`);
8487

85-
teardownCore();
88+
const mongoAggregate = await teardownCore();
89+
logCodSpeed(
90+
`[CodSpeed] Mongo Aggregate: ${JSON.stringify(mongoAggregate, null, 2)}`
91+
);
8692
}
8793
}
8894

0 commit comments

Comments
 (0)