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
class ExtendedArray extends Array {
constructor(items) {
super(items)
}
get last() {
return this[this.length - 1]
}
addToLastWithGetter(text) {
this.last.text ??= ''
this.last.text += text
}
addToLast(text) {
this[this.length - 1].text ??= ''
this[this.length - 1].text += text
}
concatToLast(text) {
this[this.length - 1].text ??= ''
this[this.length - 1].text = this[this.length - 1].text + text
}
templateStringToLast(text) {
this[this.length - 1].text ??= ''
this[this.length - 1].text = `${this[this.length - 1].text}${text}`
}
replaceWithTemplateStringToLast(text) {
const last = this[this.length - 1]
this[this.length - 1] = {
text: `${last.text}${text}`
}
}
replaceLast(text) {
const last = this[this.length - 1]
this[this.length - 1] = {
text: last.text + text,
}
}
}
let addToLastWithGetter = new ExtendedArray({text: 'x'})
let addToLast = new ExtendedArray({text: 'x'})
let concatToLast = new ExtendedArray({text: 'x'})
let templateStringToLast = new ExtendedArray({text: 'x'})
let replaceWithTemplateStringToLast = new ExtendedArray({text:'x'})
let replaceLast = new ExtendedArray({text: 'x'})
Ready to run.
Test | Ops/sec | |
---|---|---|
addToLastWithGetter |
| ready |
addToLast |
| ready |
concatToLast |
| ready |
templateStringToLast |
| ready |
replaceLast |
| ready |
replaceWithTemplateStringToLast |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.