Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,35 @@
'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();
}

View File

@ -0,0 +1,21 @@
'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);
}

View File

@ -0,0 +1,24 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [100],
});
const vm = require('vm');
const ctxFn = new vm.Script(`
var b = Math.random();
var c = a + b;
`);
function main({ n }) {
bench.start();
let context;
for (let i = 0; i < n; i++) {
context = vm.createContext({ a: 'a' });
}
bench.end(n);
ctxFn.runInContext(context);
}

View File

@ -0,0 +1,26 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1],
breakOnSigint: [0, 1],
withSigintListener: [0, 1],
});
const vm = require('vm');
function main({ n, breakOnSigint, withSigintListener }) {
const options = breakOnSigint ? { breakOnSigint: true } : {};
process.removeAllListeners('SIGINT');
if (withSigintListener)
process.on('SIGINT', () => {});
const contextifiedSandbox = vm.createContext();
bench.start();
for (let i = 0; i < n; i++)
vm.runInContext('0', contextifiedSandbox, options);
bench.end(n);
}

View File

@ -0,0 +1,24 @@
'use strict';
const common = require('../common.js');
const bench = common.createBenchmark(main, {
n: [1],
breakOnSigint: [0, 1],
withSigintListener: [0, 1],
});
const vm = require('vm');
function main({ n, breakOnSigint, withSigintListener }) {
const options = breakOnSigint ? { breakOnSigint: true } : {};
process.removeAllListeners('SIGINT');
if (withSigintListener)
process.on('SIGINT', () => {});
bench.start();
for (let i = 0; i < n; i++)
vm.runInThisContext('0', options);
bench.end(n);
}