/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v22.23.0
benchmark/vm/compile-script-in-isolate-cache.js
35 строк
1020 B
Joyee Cheung
vm: use default HDO when importModuleDynamically is not set
05 окт 2023, 03:11
Не верифицирован
05 окт 2023, 03:11
1d220b5
Код
Авторство
О чём код?
'use strict'; // This benchmarks compiling scripts that hit the in-isolate compilation // cache (by having the same source). const common = require('../common.js'); const fs = require('fs'); const vm = require('vm'); const fixtures = require('../../test/common/fixtures.js'); const scriptPath = fixtures.path('snapshot', 'typescript.js'); const bench = common.createBenchmark(main, { type: ['with-dynamic-import-callback', 'without-dynamic-import-callback'], n: [100], }); const scriptSource = fs.readFileSync(scriptPath, 'utf8'); function main({ n, type }) { let script; bench.start(); const options = {}; switch (type) { case 'with-dynamic-import-callback': // Use a dummy callback for now until we really need to benchmark it. options.importModuleDynamically = async () => {}; break; case 'without-dynamic-import-callback': break; } for (let i = 0; i < n; i++) { script = new vm.Script(scriptSource, options); } bench.end(n); script.runInThisContext(); }