JavaScript Benchmark Builder
Write two or more named JavaScript snippets, run each thousands of times in a Web Worker, and compare their ops/sec — entirely in your browser.
Input
Each snippet loops for this long; ops/sec is the iteration count divided by the actual elapsed time.
Results
Write at least 2 snippets and press Run benchmark. Everything runs in a Web Worker in your own browser — nothing is uploaded.
Guides
Paste two or more JavaScript snippets, give each one a name, and this tool runs every snippet in a tight loop to find out how many operations per second it actually sustains — then ranks them so you can see which is fastest and by how much.
It runs entirely in your browser, in a Web Worker: the timing loop executes on a background thread, so a slow or long-running snippet never freezes this tab, and nothing you paste is ever sent to a server. If a snippet is stuck in a genuine infinite loop, press Stop — it terminates the background thread immediately.
How do I use it?
- Write your first snippet (label it something meaningful, like "Array push loop").
- Add a second snippet to compare against it — up to 4 total.
- Optionally add setup code, which runs once before each timed run and is shared by every snippet (use it to build the input data a snippet needs, e.g.
const list = [1, 2, 3];, so that setup cost isn't counted in the benchmark itself). - Set how long each snippet should run for — longer runs give a steadier, less noisy measurement.
- Press Run benchmark. Results fill in live as each snippet finishes, ranked fastest first.
How is "ops/sec" measured?
Each snippet is compiled once and then called in a loop for the time budget you set. The tool counts how many calls completed and divides by the actual elapsed time (measured with performance.now()), so the result self-adjusts to how fast the current machine is — the same method benchmarking tools like Benchmark.js use. A longer time budget means more iterations and a steadier average, at the cost of a longer wait.
Why a Web Worker, if it's my own code anyway?
Running your own JavaScript in your own browser tab isn't a new capability — it's the same thing DevTools' console already lets you do. The Worker isn't a security sandbox against you; it exists so a benchmark loop — which is deliberately CPU-intensive by design — can't lock up this page's UI while it runs, and so a snippet's own globals can't collide with this tool's state. Reload or navigate away and the worker is torn down along with it.
What if a snippet throws an error?
It's reported inline as an error for that snippet, and the other snippets still run and are compared normally — one broken snippet doesn't spoil the rest of the comparison.
Does the setup code count toward the timing?
No. Setup code runs once, before the timed loop starts, specifically so that building test data (arrays, strings, objects) doesn't get counted as part of what you're actually measuring.
Is anything uploaded?
No. Every snippet, the setup code, and the results stay on your device — there's no server round-trip involved in running a benchmark.