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 testJoinPush(...args) {
const string = []
for (const item of args) {
string.push(item)
}
return string.join(' ')
}
function testJoinIndex(...args) {
const string = []
for (let idx = 0, size = args.length; idx < size; ++idx) {
string[idx] = args[idx]
}
return string.join(' ')
}
const concat = String.prototype.concat.bind(String.prototype)
function testConcat(...args) {
const [firstString, ...otherStrings] = args
let string = firstString
for (const item of otherStrings) {
string = concat(string, ' '+ item)
}
return string
}
function testAddForOf(...args) {
const [firstString, ...otherStrings] = args
let string = firstString
for (const item of otherStrings) {
string += ' '+ item
}
return string
}
function testAddForEach(...args) {
const [firstString, ...otherStrings] = args
let string = firstString
otherStrings.forEach(item => {
string += ' '+ item
})
return string
}
function testAddForLoop(...args) {
const [firstString, ...otherStrings] = args
let string = firstString
for (let idx = 0, size = otherStrings.length; idx < size; ++idx) {
string += ' '+ otherStrings[idx]
}
return string
}
function testAddWhile(...args) {
const [firstString, ...otherStrings] = args
let string = firstString
let idx = 0
const size = otherStrings.length
while (idx < size) {
string += ' '+ otherStrings[idx]
++idx
}
return string
}
const data = {
data1() {
return [
`Component1-${Date.now()} std-flex std-flex-column std-flex-align-center std-overflow-hidden`,
`Component2-${Date.now()}`,
]
},
data2() {
return [
`Component1-${Date.now()} std-flex std-flex-column std-flex-align-center std-overflow-hidden`,
`Component2-${Date.now()} std-flex std-flex-column std-flex-align-center std-overflow-hidden`,
]
},
data3() {
return [
`Component1-${Date.now()} std-flex std-flex-column std-flex-align-center std-overflow-hidden`,
`Component2-${Date.now()} std-flex std-flex-column std-flex-align-center std-overflow-hidden`,
`Component3-${Date.now()} std-flex std-flex-column std-flex-align-center std-overflow-hidden`,
`Component4-${Date.now()} std-flex std-flex-column std-flex-align-center std-overflow-hidden`,
]
},
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Join with push |
| ready |
Join with index |
| ready |
Concat |
| ready |
Add with for-of |
| ready |
Add with for-each |
| ready |
Add with for-loop |
| ready |
Add with while |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.