jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
Benchmarks array iteration constructs in a getAtPath-like traversal (property access + early-exit). Uses hit and miss paths. sink prevents DCE.
"use strict";
const isObjectLike = (v) => v != null && (typeof v === "object" || typeof v === "function");
const buildRoot = () => {
const users = Array.from({ length: 200 }, (_, i) => ({
id: i,
profile: {
name: `user${i}`,
tags: ["alpha", "beta", "gamma"],
flags: { active: (i & 1) === 0, admin: (i % 17) === 0 },
settings: { theme: i % 3 ? "dark" : "light" },
},
}));
const items = Array.from({ length: 200 }, (_, i) => ({
name: `item${i}`,
deep: { value: i, nested: { ok: true } },
}));
const meta = { "some.key": { value: 9 }, "a b": 7, 'he said "hi"': 1, "it's ok": 2, "a\\b": 3 };
const rootObject = {
version: 1,
env: { region: "eu-west-2", build: "local" },
users,
something: { items },
meta,
matrix: Array.from({ length: 40 }, (_, r) => Array.from({ length: 40 }, (_, c) => r * 40 + c)),
};
rootObject.a = { b: { c: { value: 123 } } };
return rootObject;
};
const root = buildRoot();
const segmentsHit = ["a", "b", "c", "value"];
const segmentsMiss = ["a", "missing", "x", "y"];
// Prevent DCE
let sink = 0;
// expose to avoid DCE across harnesses
window.__sink = sink;
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| HIT - index for | | ready |
| HIT - while | | ready |
| HIT - for..of | | ready |
| HIT - forEach (flag) | | ready |
| HIT - reduce | | ready |
| MISS - index for | | ready |
| MISS - while | | ready |
| MISS - for..of | | ready |
| MISS - reduce | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.