summaryrefslogtreecommitdiff
path: root/benchmark/vm/run-in-this-context.js
blob: a0c737f46954f18809386feffc211fb2fe18d71e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
'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;

  bench.start();
  for (; i < n; i++)
    vm.runInThisContext('0', options);
  bench.end(n);
}