Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F4444387
bench_jit_captured_param_bailout.cjs
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
bench_jit_captured_param_bailout.cjs
View Options
const now = () => (typeof performance !== 'undefined' && performance.now ? performance.now() : Date.now());
function readScale() {
if (typeof process === 'undefined' || !process || !process.argv) return 1;
const raw = Number(process.argv[2]);
return Number.isFinite(raw) && raw > 0 ? raw : 1;
}
const SCALE = readScale();
const REPEATS = 5;
function bench(name, rounds, fn) {
fn(Math.max(1, (rounds / 8) | 0));
const samples = [];
let out = 0;
for (let i = 0; i < REPEATS; i++) {
const t0 = now();
out = fn(rounds);
samples.push(now() - t0);
}
let best = samples[0];
let sum = 0;
for (let i = 0; i < samples.length; i++) {
if (samples[i] < best) best = samples[i];
sum += samples[i];
}
const avg = sum / samples.length;
console.log(`${name}: best ${best.toFixed(2)} ms, avg ${avg.toFixed(2)} ms, out ${out}`);
return out;
}
function hotCapturedParamBailout(rounds) {
function f(val, y) {
const g = () => val;
if (typeof y === 'number') return g();
return 0;
}
let sum = 0;
for (let i = 0; i < rounds; i++) sum += f(i, i);
return sum;
}
const rounds = 8_000_000 * SCALE;
console.log(`jit captured-param bailout benchmark (${rounds} rounds)`);
bench('captured param + bailout', rounds, hotCapturedParamBailout);
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Sat, May 2, 10:17 AM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
542455
Default Alt Text
bench_jit_captured_param_bailout.cjs (1 KB)
Attached To
Mode
rANT Ant
Attached
Detach File
Event Timeline
Log In to Comment