WebAssembly benchmark
JavaScript vs Rust WASM
Both implementations run the exact same CPU-heavy loop in your browser. Compare wall-clock time and see how WebAssembly handles number crunching.
What is being measured?
Each run sums i² for every integer from
0 to N − 1 in a tight loop — no DOM updates,
no network, just pure computation.
The JavaScript version runs on the main thread. The Rust code is compiled
to WebAssembly and called through wasm-bindgen.
At 1M and 5M, we use the original blog timing
(one JS run, then one WASM run). Larger workloads add warmup and multiple samples.
Hard limit: ~4,294M iterations (Rust u32 max). 1000M can freeze the tab for minutes.
Loading Rust WASM module…
Results
Ready
- Iterations
- —
- JavaScript result
- —
- WASM result
- —
- JavaScript samples
- —
- WASM samples
- —
- Time difference
- —
- Timing method
- —
- Outputs match
- —
How to read this
- At 1M and 5M, timing matches the original blog demo — one JS run, then WASM. That often shows a larger gap because WASM is native code while V8 is still optimizing the JS loop.
- At 10M+, we warmup and take multiple samples for stabler numbers. Ties or small gaps there are normal on modern V8.
- At 100M+, each runtime is measured in its own block (WASM first, then JS) so a hot CPU does not skew results.
- 1000M runs once per runtime only — it can freeze the tab for minutes. The code limit is ~4,294M (
u32). - Both implementations must return the same numeric result — that confirms the comparison is fair.