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
Testing the difference between creating an instance of Intl.DateTimeFormat
each time or caching the instance but either deriving the key using JSON.stringify
or manually making they key.
function extractDateParts(formatter, date, options){
const dateParts = formatter.formatToParts(date);
const configuredDatePartTypes = Object.keys(options);
return dateParts.reduce(
(acc, datePart) => {
if (configuredDatePartTypes.includes(datePart.type)) {
acc[datePart.type] = datePart.value;
}
return acc;
},
{
day: '',
month: '',
year: '',
weekday: ''
}
);
}
const formattersJson = {};
const formattersManual = {};
const formattersManualMap = {};
const formattersManualReducer = {};
const locale = 'fr-FR';
const options = {
day: 'numeric',
month: 'long',
year: '2-digit',
weekday: 'long'
};
const optionKeys = Object.keys(options);
Ready to run.
Test | Ops/sec | |
---|---|---|
No cache |
| ready |
With cache using JSON.stringify |
| ready |
With manual cache key |
| ready |
With manual cache key using an array with map/join |
| ready |
With manual cache key using an array with reducer |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.