mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
3b0617dd19
This patch migrates ContextifyScript to cppgc-based memory management using CppgcMixin. PR-URL: https://github.com/nodejs/node/pull/52295 Refs: https://github.com/nodejs/node/issues/40786 Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
'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 path = require('path');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
type: ['with-dynamic-import-callback', 'without-dynamic-import-callback'],
|
|
filename: ['test/fixtures/snapshot/typescript.js', 'test/fixtures/syntax/good_syntax.js'],
|
|
n: [1000],
|
|
});
|
|
|
|
function main({ n, type, filename }) {
|
|
const scriptPath = path.resolve(__dirname, '..', '..', filename);
|
|
const scriptSource = fs.readFileSync(scriptPath, 'utf8');
|
|
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();
|
|
}
|