Skip to content

Commit

Permalink
benchmark: add vm context global proxy benchmark
Browse files Browse the repository at this point in the history
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 27b4b78
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions benchmark/vm/context-global-proxy.js
@@ -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.