Skip to content

Commit b3bbe42

Browse files
committed
fix: enable v8 optimizations in benchmark.js suites
1 parent ac539c9 commit b3bbe42

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/benchmark.js/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ function withCodSpeedSuite(suite: Benchmark.Suite): Benchmark.Suite {
5858
};
5959
return suite;
6060
}
61+
initCore();
6162
const callingFile = getCallingFile();
6263
// eslint-disable-next-line @typescript-eslint/no-unused-vars
6364
suite.run = function (options?: Benchmark.Options): Benchmark.Suite {
@@ -73,6 +74,8 @@ function withCodSpeedSuite(suite: Benchmark.Suite): Benchmark.Suite {
7374
for (let i = 0; i < benches.length; i++) {
7475
const bench = benches[i];
7576
const uri = baseUri + "::" + (bench.name ?? `unknown_${i}`);
77+
const fn = bench.fn as CallableFunction;
78+
optimizeFunctionSync(fn);
7679
measurement.startInstrumentation();
7780
(bench.fn as CallableFunction)();
7881
measurement.stopInstrumentation(uri);

0 commit comments

Comments
 (0)