0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/benchmark/vm/run-in-context.js
Sebastiaan Deckers bb29405904
lib,src: fix consistent spacing inside braces
PR-URL: https://github.com/nodejs/node/pull/14162
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-21 15:13:47 -04:00

31 lines
646 B
JavaScript

'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1],
breakOnSigint: [0, 1],
withSigintListener: [0, 1]
});
const vm = require('vm');
function main(conf) {
const n = +conf.n;
const options = conf.breakOnSigint ? { breakOnSigint: true } : {};
const withSigintListener = !!conf.withSigintListener;
process.removeAllListeners('SIGINT');
if (withSigintListener)
process.on('SIGINT', () => {});
var i = 0;
const contextifiedSandbox = vm.createContext();
bench.start();
for (; i < n; i++)
vm.runInContext('0', contextifiedSandbox, options);
bench.end(n);
}