mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
755 B
33 lines
755 B
8 years ago
|
'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();
|
||
|
|
||
|
common.v8ForceOptimization(vm.runInContext,
|
||
|
'0', contextifiedSandbox, options);
|
||
|
bench.start();
|
||
|
for (; i < n; i++)
|
||
|
vm.runInContext('0', contextifiedSandbox, options);
|
||
|
bench.end(n);
|
||
|
}
|