JS vs WASM Pathfinding

Methodology

Methodology

The numbers are the truth, the animation is a slowed-down replay.

The reported Time is measured inside each Web Worker around the algorithm only — from performance.now() immediately before the call to immediately after it returns. It excludes worker startup, postMessage transfer, and rendering.

The visited cells you see filling each canvas are not painted in real time. The worker runs the full search first and returns the entire visited array; the main thread then animates that array onto the canvas proportional to the measured algorithm time, scaled up by a constant factor so millisecond-scale runs are watchable (currently 50×, clamped to 150ms–5000ms). Both panes use the same scale, so the relative wall-clock duration on screen reflects the ratio of the underlying algorithm times.

Both implementations operate on identical grid bytes (seeded mulberry32), identical neighbor order (up, down, left, right), identical heap discipline, and the same Manhattan heuristic for A*. The node count printed under each canvas is the same on both sides for the same seed — that's the fairness check.

JavaScript

Idle

WebAssembly

Idle