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 baseWord = "aBcDeFgHiJkLmNo";
const createMatchingWord = () => Array.from({length: 15}, (_, index) => {
const letter = String.fromCharCode('a'.charCodeAt(0) + index);
if (Math.random() > 0.5) {
return letter.toUpperCase();
}
return letter;
}).join('');
const matchingWords = Array.from({length: 50000}, createMatchingWord);
const minCodePoint = 'b'.charCodeAt(0);
const maxCodePoint = 'z'.charCodeAt(0);
const randomLetter = () => {
const letter = String.fromCharCode(Math.floor(Math.random() * (maxCodePoint - minCodePoint) + minCodePoint));
if (Math.random() > 0.5) {
return letter.toUpperCase();
}
return letter;
};
const createFailingWord = () => Array.from({length: 15}, randomLetter).join('');
const failingWords = Array.from({length: 50000}, createFailingWord);
const run = (equalsFn) => {
for (const word of matchingWords) {
if (!equalsFn(baseWord, word)) {
throw new Error("Unexpected result");
}
}
for (const word of failingWords) {
if (equalsFn(baseWord, word)) {
throw new Error("Unexpected result");
}
}
};
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| toUpper strict equals | | ready |
| localeCompare base (note that 'accent' returns similar results) | | ready |
| Regex | | ready |
| Regex pre-prepared | | ready |
| Intl.Collator | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.