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
compare twJoin vs simply using template literals
const someStyle = 'focus-visible:rounded-50 focus-visible:outline focus-visible:outline-200 focus-visible:outline-offset-25 focus-visible:outline-interactive-focus';
function twJoin() {
let index = 0
let argument
let resolvedValue
let string = ""
while (index < arguments.length) {
if ((argument = arguments[index++])) {
if ((resolvedValue = toValue(argument))) {
string && (string += " ")
string += resolvedValue
}
}
}
return string
}
const toValue = mix => {
if (typeof mix === "string") {
return mix
}
let resolvedValue
let string = ""
for (let k = 0; k < mix.length; k++) {
if (mix[k]) {
if ((resolvedValue = toValue(mix[k]))) {
string && (string += " ")
string += resolvedValue
}
}
}
return string
}
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Template literal | | ready |
| twJoin | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.