Skip to content

Commit 4051073

Browse files
committed
support async benchmark tests
1 parent 0978057 commit 4051073

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

benchmark/benchmark.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,9 @@ function sampleModule(modulePath: string): Promise<BenchmarkSample> {
371371
372372
clock(7, benchmark.measure); // warm up
373373
global.gc();
374-
process.nextTick(() => {
374+
process.nextTick(async () => {
375375
const memBaseline = process.memoryUsage().heapUsed;
376-
const clocked = clock(benchmark.count, benchmark.measure);
376+
const clocked = await clock(benchmark.count, benchmark.measure);
377377
process.send({
378378
name: benchmark.name,
379379
clocked: clocked / benchmark.count,
@@ -382,10 +382,10 @@ function sampleModule(modulePath: string): Promise<BenchmarkSample> {
382382
});
383383
384384
// Clocks the time taken to execute a test per cycle (secs).
385-
function clock(count, fn) {
385+
async function clock(count, fn) {
386386
const start = process.hrtime.bigint();
387387
for (let i = 0; i < count; ++i) {
388-
fn();
388+
await fn();
389389
}
390390
return Number(process.hrtime.bigint() - start);
391391
}

0 commit comments

Comments
 (0)