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 usingSet(...ariaLists) {
const dedupedAriaListSet = new Set()
const output = []
ariaLists.forEach(list => {
list?.split(' ').forEach(value => {
if (value) {
if (!dedupedAriaListSet.has(value)) output.push(value)
dedupedAriaListSet.add(value)
}
})
})
return output.length > 0 ? output.join(' ') : undefined
}
function usingArrayIncludes(...ariaLists) {
const flattened = []
ariaLists.forEach(value => {
if (value) {
value
.trim()
.split(' ')
.forEach(val => {
if (val !== '' && !flattened.includes(val)) flattened.push(val)
})
}
})
return flattened.length > 0 ? flattened.join(' ').trim() : undefined
}
function usingSetArrayFrom(...ariaLists) {
const dedupedAriaListSet = new Set()
ariaLists.forEach(list => {
list?.split(' ').forEach(value => {
if (value) dedupedAriaListSet.add(value)
})
})
return dedupedAriaListSet.size > 0 ? Array.from(dedupedAriaListSet).join(' ') : undefined
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Using set |
| ready |
Using array.includes |
| ready |
Using set & array.from |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.