Skip to content

Commit 961d8a2

Browse files
committed
support async benchmark tests
1 parent 7ca43c8 commit 961d8a2

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
@@ -341,9 +341,9 @@ function sampleModule(modulePath) {
341341
342342
clock(7, module.measure); // warm up
343343
global.gc();
344-
process.nextTick(() => {
344+
process.nextTick(async () => {
345345
const memBaseline = process.memoryUsage().heapUsed;
346-
const clocked = clock(module.count, module.measure);
346+
const clocked = await clock(module.count, module.measure);
347347
process.send({
348348
name: module.name,
349349
clocked: clocked / module.count,
@@ -352,10 +352,10 @@ function sampleModule(modulePath) {
352352
});
353353
354354
// Clocks the time taken to execute a test per cycle (secs).
355-
function clock(count, fn) {
355+
async function clock(count, fn) {
356356
const start = process.hrtime.bigint();
357357
for (let i = 0; i < count; ++i) {
358-
fn();
358+
await fn();
359359
}
360360
return Number(process.hrtime.bigint() - start);
361361
}

0 commit comments

Comments
 (0)