new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vitest · Guide · all subjects

benchmarking/engines

7 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

V8 JIT tiering considerations in benchmarks

V8 compiles functions through multiple optimization tiers (Sparkplug → Maglev → TurboFan). A function may run at different speeds during warmup vs. steady-state. Tinybench handles warmup automatically, but very short benchmark runs may not reach the highest optimization tier.

V8 deoptimization pitfall in benchmarks

V8 can bail out of optimized code mid-benchmark if it encounters unexpected types or shapes. Keep the types consistent in your benchmark function to avoid deoptimization.

Example of V8 deoptimization pitfall

test('process items', async ({ bench }) => { // BAD: mixed shapes cause deoptimization await bench('process', () => { for (const item of items) { // some items have { name: string }, others have { name: string, id: number } process(item) } }).run() // GOOD: consistent object shapes await bench('process', () => { for (const item of items) { // all items have the same shape { name: string, id: number } process(item) } }).run() })

V8 garbage collection considerations in benchmarks

Large allocations inside the benchmark loop add GC noise. If you are measuring computation, pre-allocate data in a setup hook rather than inside the benchmarked function.

Example of pre-allocating data in benchmarks

test('sorting', async ({ bench }) => { const original = Array.from({ length: 10000 }, () => Math.random()) let data: number[] // BAD: allocates a new array every iteration, GC adds noise await bench('sort', () => { const data = Array.from({ length: 10000 }, () => Math.random()) data.sort() }).run() // GOOD: pre-allocate, copy in beforeEach await bench( 'sort', () => { data.sort() }, { beforeEach() { data = [...original] }, }, ).run() })

JavaScriptCore optimization thresholds differ from V8

JSC uses its own JIT tiers (LLInt → Baseline → DFG → FTL) with different inlining and optimization heuristics. A benchmark that is fast on V8 may behave very differently on JSC.

JavaScriptCore async benchmark differences

Bun's event loop implementation differs from Node.js. If your benchmark involves async operations or timers, results may not be directly comparable across runtimes.

Give your agent this brain