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 APP_NAME = 'Testing';
const joinAndIfs = (pageTitle, pageSubtitle) => {
const titleParts = [APP_NAME];
if (pageTitle) {
titleParts.push(pageTitle);
if (pageSubtitle) titleParts.push(pageSubtitle);
}
return titleParts.join(' - ');
}
const joinAndFilters = (pageTitle, pageSubtitle) => {
const titleParts = [APP_NAME, pageTitle, pageSubtitle];
return titleParts.filter((s) => !!s).join(' - ');
}
const stringConcat = (pageTitle, pageSubtitle) => {
let title = APP_NAME;
if (pageTitle) {
title += ' - ' + pageTitle;
if (pageSubtitle) title += ' - ' + pageSubtitle;
}
return title;
}
const earlyReturnsConcat = (pageTitle, pageSubtitle) => {
let title = APP_NAME;
if (!pageTitle) return title;
title += ' - ' + pageTitle;
if (!pageSubtitle) return title;
title += ' - ' + pageSubtitle;
return title
}
const earlyReturnsJoinArr = (pageTitle, pageSubtitle) => {
if (!pageTitle) return [APP_NAME];
if (!pageSubtitle) return [APP_NAME, pageTitle];
return [APP_NAME, pageTitle, pageSubtitle];
}
const earlyReturnsJoin = (...args) => {
return earlyReturnsJoinArr(...args).join(' - ');
}
Ready to run.
Test | Ops/sec | |
---|---|---|
joinAndIfs |
| ready |
joinAndFilters |
| ready |
stringConcat |
| ready |
earlyReturnsConcat |
| ready |
earlyReturnsJoin |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.