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
const makeKey = () => ('' + (10000 + Math.floor(Math.random() * 90000))); // string 10000-99999
const KEYS = Array.from(new Set(Array(100).fill(0).map(makeKey))).slice(0, 30); // 30 random strings
const getRandomKey = () => KEYS[Math.floor(Math.random() * KEYS.length)];
const makeKeysAmount = () => (5 + Math.round(Math.random() * 10)); // number 5-15
const makeRecordKeys = () => Array(makeKeysAmount()).fill(0).map(() => getRandomKey()); // array of random amount of random keys
const makeRecord = () => makeRecordKeys().reduce((o, k) => {
o[k] = true;
return o;
}, {}); // object like `{ 9: true, 14: true, 17: true, 24: true, 26: true, 29: true }`
const input = Array(1000).fill(0).map(() => makeRecord());Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Collect then deduplicate | | ready |
| Double for | | ready |
| Double forEach | | ready |
| Union | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.