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 clsx
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
}
function toVal(mix) {
var k, y, str='';
if (typeof mix === 'string' || typeof mix === 'number') {
str += mix;
} else if (typeof mix === 'object') {
if (Array.isArray(mix)) {
var len=mix.length;
for (k=0; k < len; k++) {
if (mix[k]) {
if (y = toVal(mix[k])) {
str && (str += ' ');
str += y;
}
}
}
} else {
for (y in mix) {
if (mix[y]) {
str && (str += ' ');
str += y;
}
}
}
}
return str;
}
function clsx() {
var i=0, tmp, x, str='', len=arguments.length;
for (; i < len; i++) {
if (tmp = arguments[i]) {
if (x = toVal(tmp)) {
str && (str += ' ');
str += x
}
}
}
return str;
}
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| twJoin | | ready |
| clsx | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.