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
function createObj (keyLength, nKeys) {
const obj = {};
for (let i = 0; i < nKeys; i++) {
const key = randStr(keyLength);
// Random value, just in the case the engine does some optimizations under the hood
obj[key] = randStr(32);
}
return obj;
}
function randStr(length) {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
}
function testRead(obj) {
let sum = 0;
Object.keys(obj).forEach((key) => {
sum += obj[key].length;
});
return sum;
}
const n = 32;
// Create the objects upfront; the tests are about reading from them, not creation time
let objects = {
10: createObj(10, n),
100: createObj(100, n),
1000: createObj(1000, n),
10_000: createObj(10_000, n),
13_750: createObj(13_750, n),
15_000: createObj(15_000, n),
16_250: createObj(16_250, n),
17_500: createObj(17_500, n),
25_000: createObj(25_000, n),
50_000: createObj(50_000, n),
100_000: createObj(100_000, n),
// These make Chrome very sad
// 1_000_000: createObj(1_000_000, n),
// 10_000_000: createObj(10_000_000, n)
}
Ready to run.
Test | Ops/sec | |
---|---|---|
10 |
| ready |
10_000 |
| ready |
13_750 |
| ready |
15_000 |
| ready |
16_250 |
| ready |
17_500 |
| ready |
25_000 |
| ready |
50_000 |
| ready |
100_000 |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.