Skip to content

Commit 27b4b78

Browse files
joyeecheungdanielleadams
authored andcommitted
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>
1 parent 67eaa30 commit 27b4b78

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

benchmark/vm/context-global-proxy.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
5+
const bench = common.createBenchmark(main, {
6+
n: [100000],
7+
});
8+
9+
const vm = require('vm');
10+
const script = new vm.Script(`
11+
globalThis.foo++;
12+
`);
13+
const context = vm.createContext({ foo: 1 });
14+
15+
function main({ n }) {
16+
bench.start();
17+
for (let i = 0; i < n; i++) {
18+
script.runInContext(context);
19+
}
20+
bench.end(n);
21+
}

0 commit comments

Comments
 (0)