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 dcdb96c

Browse filesBrowse files
joyeecheungtargos
authored andcommitted
benchmark: add benchmark for vm.createContext
PR-URL: #29845 Refs: #29842 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent ddbf150 commit dcdb96c
Copy full SHA for dcdb96c

File tree

Expand file treeCollapse file tree

1 file changed

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

1 file changed

+24
-0
lines changed
Open diff view settings
Collapse file

‎benchmark/vm/create-context.js‎

Copy file name to clipboard
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
3+
const common = require('../common.js');
4+
5+
const bench = common.createBenchmark(main, {
6+
n: [100]
7+
});
8+
9+
const vm = require('vm');
10+
11+
const ctxFn = new vm.Script(`
12+
var b = Math.random();
13+
var c = a + b;
14+
`);
15+
16+
function main({ n }) {
17+
bench.start();
18+
let context;
19+
for (let i = 0; i < n; i++) {
20+
context = vm.createContext({ a: 'a' });
21+
}
22+
bench.end(n);
23+
ctxFn.runInContext(context);
24+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.