Skip to content
Permalink
Browse files

benchmark: add benchmark for vm.createContext

PR-URL: #29845
Refs: #29842
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
joyeecheung authored and targos committed Oct 4, 2019
1 parent ddbf150 commit dcdb96c7bb9294cf00bdd75e34fa087f011215aa
Showing with 24 additions and 0 deletions.
  1. +24 −0 benchmark/vm/create-context.js
@@ -0,0 +1,24 @@
'use strict';

const common = require('../common.js');

const bench = common.createBenchmark(main, {
n: [100]
});

const vm = require('vm');

const ctxFn = new vm.Script(`
var b = Math.random();
var c = a + b;
`);

function main({ n }) {
bench.start();
let context;
for (let i = 0; i < n; i++) {
context = vm.createContext({ a: 'a' });
}
bench.end(n);
ctxFn.runInContext(context);
}

0 comments on commit dcdb96c

Please sign in to comment.
You can’t perform that action at this time.