mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
b3531bf735
PR-URL: https://github.com/nodejs/node/pull/44796 Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
22 lines
377 B
JavaScript
22 lines
377 B
JavaScript
'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);
|
|
}
|