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 basename(path) {
return path.substring(path.lastIndexOf("/") + 1)
}
function groupFilesMap(filePaths) {
const groups = new Map();
for (const filePath of filePaths) {
const filename = basename(filePath);
const [prefix, ...suffixes] = filename.split('.');
let group = groups.get(prefix);
if (!group) {
group = {path: filePath, children: []};
groups.set(prefix, group);
}
if (suffixes[0] == 'razor' || suffixes[0] == 'cshtml') {
if (suffixes.length == 1) {
group.path = filePath;
} else {
group.children.push(filePath);
}
}
}
return groups.values();
}
function groupFilesObject(filePaths) {
const groups = {};
for (const filePath of filePaths) {
const filename = basename(filePath);
const [prefix, ...suffixes] = filename.split('.');
let group = groups[prefix];
if (!group) {
group = groups[prefix] = {path: filePath, children: []};
}
if (suffixes[0] == 'razor' || suffixes[0] == 'cshtml') {
if (suffixes.length == 1) {
group.path = filePath;
} else {
group.children.push(filePath);
}
}
}
return Object.values(groups);
}
const data = ["/Index.razor", "/Index.razor.js", "/Index.razor.css", "/foo", "/bar", "/baz"];
Ready to run.
Test | Ops/sec | |
---|---|---|
Map |
| ready |
Object |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.