Skip to content

Commit

Permalink
chore: remove calls to mongoMeasurement - DO NOT MERGE
Browse files Browse the repository at this point in the history
  • Loading branch information
adriencaccia committed Jan 17, 2024
1 parent 4662ad7 commit 382f368
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
8 changes: 4 additions & 4 deletions packages/benchmark.js-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,22 @@ async function runBenchmarks({

if (isAsync) {
await optimizeFunction(benchPayload);
await mongoMeasurement.start(uri);
// await mongoMeasurement.start(uri);
await (async function __codspeed_root_frame__() {
Measurement.startInstrumentation();
await benchPayload();
Measurement.stopInstrumentation(uri);
})();
await mongoMeasurement.stop(uri);
// await mongoMeasurement.stop(uri);
} else {
optimizeFunctionSync(benchPayload);
await mongoMeasurement.start(uri);
// await mongoMeasurement.start(uri);
(function __codspeed_root_frame__() {
Measurement.startInstrumentation();
benchPayload();
Measurement.stopInstrumentation(uri);
})();
await mongoMeasurement.stop(uri);
// await mongoMeasurement.stop(uri);
}

if (typeof bench.options.teardown === "function") {
Expand Down
4 changes: 2 additions & 2 deletions packages/tinybench-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ export function withCodSpeed(bench: Bench): Bench {
// run instrumented benchmark
await task.opts.beforeEach?.call(task);

await mongoMeasurement.start(uri);
// await mongoMeasurement.start(uri);
await (async function __codspeed_root_frame__() {
Measurement.startInstrumentation();
await task.fn();
Measurement.stopInstrumentation(uri);
})();
await mongoMeasurement.stop(uri);
// await mongoMeasurement.stop(uri);

await task.opts.afterEach?.call(task);

Expand Down
26 changes: 13 additions & 13 deletions packages/tinybench-plugin/tests/index.integ.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe("Benchmark.Suite", () => {
await bench.run();

expect(onComplete).toHaveBeenCalled();
expect(mockCore.mongoMeasurement.start).not.toHaveBeenCalled();
expect(mockCore.mongoMeasurement.stop).not.toHaveBeenCalled();
// expect(mockCore.mongoMeasurement.start).not.toHaveBeenCalled();
// expect(mockCore.mongoMeasurement.stop).not.toHaveBeenCalled();
expect(mockCore.Measurement.startInstrumentation).not.toHaveBeenCalled();
expect(mockCore.Measurement.stopInstrumentation).not.toHaveBeenCalled();
});
Expand All @@ -42,10 +42,10 @@ describe("Benchmark.Suite", () => {
})
.run();

expect(mockCore.mongoMeasurement.start).toHaveBeenCalledWith(
"packages/tinybench-plugin/tests/index.integ.test.ts::RegExp"
);
expect(mockCore.mongoMeasurement.stop).toHaveBeenCalledTimes(1);
// expect(mockCore.mongoMeasurement.start).toHaveBeenCalledWith(
// "packages/tinybench-plugin/tests/index.integ.test.ts::RegExp"
// );
// expect(mockCore.mongoMeasurement.stop).toHaveBeenCalledTimes(1);
expect(mockCore.Measurement.startInstrumentation).toHaveBeenCalled();
expect(mockCore.Measurement.stopInstrumentation).toHaveBeenCalledWith(
"packages/tinybench-plugin/tests/index.integ.test.ts::RegExp"
Expand All @@ -62,13 +62,13 @@ describe("Benchmark.Suite", () => {
})
.run();

expect(mockCore.mongoMeasurement.start).toHaveBeenCalledWith(
"packages/tinybench-plugin/tests/index.integ.test.ts::RegExp"
);
expect(mockCore.mongoMeasurement.start).toHaveBeenCalledWith(
"packages/tinybench-plugin/tests/index.integ.test.ts::RegExp2"
);
expect(mockCore.mongoMeasurement.stop).toHaveBeenCalledTimes(2);
// expect(mockCore.mongoMeasurement.start).toHaveBeenCalledWith(
// "packages/tinybench-plugin/tests/index.integ.test.ts::RegExp"
// );
// expect(mockCore.mongoMeasurement.start).toHaveBeenCalledWith(
// "packages/tinybench-plugin/tests/index.integ.test.ts::RegExp2"
// );
// expect(mockCore.mongoMeasurement.stop).toHaveBeenCalledTimes(2);
expect(mockCore.Measurement.stopInstrumentation).toHaveBeenCalledWith(
"packages/tinybench-plugin/tests/index.integ.test.ts::RegExp"
);
Expand Down
16 changes: 8 additions & 8 deletions packages/vitest-plugin/src/__tests__/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ describe("CodSpeedRunner", () => {
);

// run
expect(coreMocks.mongoMeasurement.start).toHaveBeenCalledWith(
"packages/vitest-plugin/src/__tests__/runner.test.ts::test bench"
);
// expect(coreMocks.mongoMeasurement.start).toHaveBeenCalledWith(
// "packages/vitest-plugin/src/__tests__/runner.test.ts::test bench"
// );
expect(coreMocks.Measurement.startInstrumentation).toHaveBeenCalledTimes(1);
expect(benchFn).toHaveBeenCalledTimes(2);
expect(coreMocks.Measurement.stopInstrumentation).toHaveBeenCalledTimes(1);
expect(coreMocks.mongoMeasurement.stop).toHaveBeenCalledTimes(1);
// expect(coreMocks.mongoMeasurement.stop).toHaveBeenCalledTimes(1);
expect(console.log).toHaveBeenCalledWith(
"[CodSpeed] packages/vitest-plugin/src/__tests__/runner.test.ts::test bench done"
);
Expand Down Expand Up @@ -99,13 +99,13 @@ describe("CodSpeedRunner", () => {
);

// run
expect(coreMocks.mongoMeasurement.start).toHaveBeenCalledWith(
"packages/vitest-plugin/src/__tests__/runner.test.ts::nested suite::test bench"
);
// expect(coreMocks.mongoMeasurement.start).toHaveBeenCalledWith(
// "packages/vitest-plugin/src/__tests__/runner.test.ts::nested suite::test bench"
// );
expect(coreMocks.Measurement.startInstrumentation).toHaveBeenCalledTimes(1);
expect(benchFn).toHaveBeenCalledTimes(2);
expect(coreMocks.Measurement.stopInstrumentation).toHaveBeenCalledTimes(1);
expect(coreMocks.mongoMeasurement.stop).toHaveBeenCalledTimes(1);
// expect(coreMocks.mongoMeasurement.stop).toHaveBeenCalledTimes(1);
expect(console.log).toHaveBeenCalledWith(
"[CodSpeed] packages/vitest-plugin/src/__tests__/runner.test.ts::nested suite::test bench done"
);
Expand Down
5 changes: 2 additions & 3 deletions packages/vitest-plugin/src/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
getGitDir,
logDebug,
Measurement,
mongoMeasurement,
optimizeFunction,
setupCore,
teardownCore,
Expand Down Expand Up @@ -49,14 +48,14 @@ async function runBenchmarkSuite(suite: Suite, parentSuiteName?: string) {
const fn = getBenchFn(benchmark);

await optimizeFunction(fn);
await mongoMeasurement.start(uri);
// await mongoMeasurement.start(uri);
await (async function __codspeed_root_frame__() {
Measurement.startInstrumentation();
// @ts-expect-error we do not need to bind the function to an instance of tinybench's Bench
await fn();
Measurement.stopInstrumentation(uri);
})();
await mongoMeasurement.stop(uri);
// await mongoMeasurement.stop(uri);

logCodSpeed(`${uri} done`);
}
Expand Down

0 comments on commit 382f368

Please sign in to comment.