Files
Kmake/benchmark/napi/ref/index.js

20 lines
479 B
JavaScript
Raw Permalink Normal View History

2026-05-26 23:36:42 -07:00
'use strict';
const common = require('../../common');
const addon = require(`./build/${common.buildType}/addon`);
const bench = common.createBenchmark(main, { n: [1e7] });
function callNewWeak() {
addon.newWeak();
}
function main({ n }) {
addon.count = 0;
bench.start();
new Promise((resolve) => {
(function oneIteration() {
callNewWeak();
setImmediate(() => ((addon.count < n) ? oneIteration() : resolve()));
})();
}).then(() => bench.end(n));
}