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 set = new Set();
set.add(new Date());
for (let i = 0; i < 100000; i++) {
set.add(Math.random());
}
set.add(new Date());
for (let i = 0; i < 100000; i++) {
set.add(i*10);
}
set.add(new Date());
for (let i = 0; i < 100000; i++) {
set.add(performance.now());
}
set.add(new Date());
const alph = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
const randChar = () => alph[Math.floor(Math.random()*alph.length)];
const randChars = (len = 6) => Array(len).fill(0).map(a => randChar()).join("");
for (let i = 0; i < 100000; i++) {
set.add(randChars(Math.ceil(Math.random()*100)));
}
function getFirstItemOfSet(set) {
for(let item of set) {
if(item) {
return item;
}
}
return undefined;
}
Ready to run.
Test | Ops/sec | |
---|---|---|
spread |
| ready |
iterator on keys |
| ready |
destructuring |
| ready |
getFirstItemOfSet |
| ready |
Array.from()[0] |
| ready |
iterator on values |
| ready |
set iterator symbol next |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.