Skip to content

Commit 1d1b840

Browse files
committed
support async benchmark tests
1 parent b38429f commit 1d1b840

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

benchmark/benchmark.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,9 @@ function sampleModule(modulePath) {
342342
343343
clock(7, module.measure); // warm up
344344
global.gc();
345-
process.nextTick(() => {
345+
process.nextTick(async () => {
346346
const memBaseline = process.memoryUsage().heapUsed;
347-
const clocked = clock(module.count, module.measure);
347+
const clocked = await clock(module.count, module.measure);
348348
process.send({
349349
name: module.name,
350350
clocked: clocked / module.count,
@@ -353,10 +353,10 @@ function sampleModule(modulePath) {
353353
});
354354
355355
// Clocks the time taken to execute a test per cycle (secs).
356-
function clock(count, fn) {
356+
async function clock(count, fn) {
357357
const start = process.hrtime.bigint();
358358
for (let i = 0; i < count; ++i) {
359-
fn();
359+
await fn();
360360
}
361361
return Number(process.hrtime.bigint() - start);
362362
}

0 commit comments

Comments
 (0)