Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class Suite {
}

// It doesn't make sense to warmup a fresh new instance of Worker.
// TODO: support warmup directly in the Worker.
// TODO: Should this be folded into the main loop?
if (!this.#useWorkers) {
// This is required to avoid variance on first benchmark run
for (let i = 0; i < this.#benchmarks.length; ++i) {
Expand Down
17 changes: 16 additions & 1 deletion lib/worker-runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
const { parentPort } = require("node:worker_threads");
const { runBenchmark } = require("./lifecycle");
const {
runBenchmark,
getInitialIterations,
runWarmup,
} = require("./lifecycle");
const { debugBench } = require("./clock");
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;

// Deserialize the benchmark function
Expand All @@ -24,6 +29,16 @@ parentPort.on(
minSamples,
}) => {
deserializeBenchmark(benchmark);

debugBench(
`Warmup ${benchmark.name} with minTime=${benchmark.minTime}, maxTime=${benchmark.maxTime}`,
);
const initialIteration = await getInitialIterations(benchmark);
await runWarmup(benchmark, initialIteration, {
minTime: 0.005,
maxTime: 0.05,
});

const result = await runBenchmark(
benchmark,
initialIterations,
Expand Down
Loading