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
Tests /^prefix/.test() vs String.startsWith("prefix")
const getRandomPart = () => Math.random().toString(36).substring(2, 8);
const getRandomLength = () => Math.floor(Math.random() * 4) + 2; // 2 to 5 parts
const strings = Array.from({ length: 100 }, (_, i) => {
const parts = Array.from({ length: getRandomLength() }, getRandomPart);
let str = parts.join('.');
if (Math.random() < 0.3) { // ~30% start with prefix!
str = 'prefix!' + str;
}
return str;
});
Ready to run.
Test | Ops/sec | |
---|---|---|
Regex match |
| ready |
Regex test |
| ready |
String.startsWith |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.