1'use strict'; 2const common = require('../../common'); 3const addon = require(`./build/${common.buildType}/addon`); 4const bench = common.createBenchmark(main, { n: [1e7] }); 5 6function callNewWeak() { 7 addon.newWeak(); 8} 9 10function main({ n }) { 11 addon.count = 0; 12 bench.start(); 13 new Promise((resolve) => { 14 (function oneIteration() { 15 callNewWeak(); 16 setImmediate(() => ((addon.count < n) ? oneIteration() : resolve())); 17 })(); 18 }).then(() => bench.end(n)); 19} 20