Skip to content

Commit 84579e3

Browse files
committed
support async benchmark tests
1 parent c7d7026 commit 84579e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

resources/benchmark.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,9 +369,9 @@ function sampleModule(modulePath: string): Promise<BenchmarkSample> {
369369
370370
clock(7, benchmark.measure); // warm up
371371
global.gc();
372-
process.nextTick(() => {
372+
process.nextTick(async () => {
373373
const memBaseline = process.memoryUsage().heapUsed;
374-
const clocked = clock(benchmark.count, benchmark.measure);
374+
const clocked = await clock(benchmark.count, benchmark.measure);
375375
process.send({
376376
name: benchmark.name,
377377
clocked: clocked / benchmark.count,
@@ -380,10 +380,10 @@ function sampleModule(modulePath: string): Promise<BenchmarkSample> {
380380
});
381381
382382
// Clocks the time taken to execute a test per cycle (secs).
383-
function clock(count, fn) {
383+
async function clock(count, fn) {
384384
const start = process.hrtime.bigint();
385385
for (let i = 0; i < count; ++i) {
386-
fn();
386+
await fn();
387387
}
388388
return Number(process.hrtime.bigint() - start);
389389
}

0 commit comments

Comments
 (0)