Skip to content

Commit b3531bf

Browse files
committed
benchmark: add vm context global proxy benchmark
PR-URL: #44796 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d5ce285 commit b3531bf

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

benchmark/vm/context-global-proxy.js

Lines changed: 21 additions & 0 deletions
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)