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
const input = {
color: {
primary: {
$value: "#3490dc",
$type: "color",
},
secondary: {
$value: "#ffed4a",
$type: "color",
},
neutral: {
light: {
thing: {
$value: "#f5f5f5",
$type: "color",
}
},
dark: {
$value: "#333333",
$type: "color",
},
},
otherneutral: {
light: {
thing: {
$value: "#f5f5f5",
$type: "color",
}
},
dark: {
$value: "#333333",
$type: "color",
},
},
}
};
const traverseTokenGroup = (jsonObj, label, output) => {
if (!jsonObj) return "";
Object.entries(jsonObj).forEach(([key, value]) => {
if (key === "$value" || key === "$type") {
return;
}
if (typeof value === 'object') {
if (Object.keys(value).includes("$value")) {
const leafNode = value;
output.push(` ${label}-${key}: ${leafNode.$value};`);
}
traverseTokenGroup(value, `${label}-${key}`, output);
}
});
return output.join("\n");
};
const traverseTokenGroup2 = (obj, currentLabel) => {
return Object.entries(obj).reduce((acc, [key, value]) => {
if (key === "$value" || key === "$type") {
return acc;
}
if (typeof value === 'object') {
if (Object.keys(value).includes("$value")) {
acc += ` ${currentLabel}-${key}: ${value.$value};\n`;
}
acc += traverseTokenGroup2(value, `${currentLabel}-${key}`);
}
return acc;
}, '');
};
const enc = new TextEncoder()
Ready to run.
Test | Ops/sec | |
---|---|---|
Array Join |
| ready |
String Concat |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.