Skip to content
Permalink
Browse files
benchmark: add vm context global proxy benchmark
PR-URL: #44796
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
joyeecheung authored and danielleadams committed Oct 6, 2022
1 parent 67eaa30 commit 27b4b782ce6864ead7d7a67ee814cd414b628e9a
Showing 1 changed file with 21 additions and 0 deletions.
@@ -0,0 +1,21 @@
'use strict';

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

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

const vm = require('vm');
const script = new vm.Script(`
globalThis.foo++;
`);
const context = vm.createContext({ foo: 1 });

function main({ n }) {
bench.start();
for (let i = 0; i < n; i++) {
script.runInContext(context);
}
bench.end(n);
}

0 comments on commit 27b4b78

Please sign in to comment.