1'use strict'; 2 3const common = require('../common.js'); 4 5const bench = common.createBenchmark(main, { 6 n: [1], 7 breakOnSigint: [0, 1], 8 withSigintListener: [0, 1] 9}); 10 11const vm = require('vm'); 12 13function main({ n, breakOnSigint, withSigintListener }) { 14 const options = breakOnSigint ? { breakOnSigint: true } : {}; 15 16 process.removeAllListeners('SIGINT'); 17 if (withSigintListener) 18 process.on('SIGINT', () => {}); 19 20 const contextifiedSandbox = vm.createContext(); 21 22 bench.start(); 23 for (let i = 0; i < n; i++) 24 vm.runInContext('0', contextifiedSandbox, options); 25 bench.end(n); 26} 27