Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 27b4b78

Browse filesBrowse 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
Copy full SHA for 27b4b78

File tree

Expand file treeCollapse file tree

1 file changed

+21
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-0
lines changed
Open diff view settings
Collapse file
+21Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.