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 randomInt = (s, e) => s + (Math.random() * (e - s) | 0);
const randomLetter = () => String.fromCharCode(randomInt(65, 65 + 26));
const makeArray = (n, f) => [...new Array(n)].map((_, i) => f(i));
const randValues = makeArray(1000, () => makeArray(10, randomLetter).join(''));
const randPatterns = randValues.map((v) => [...v].map(x => `${x}{1,${randomInt(2,9)}}`).join(''));
const samePattern = makeArray(100, () => randPatterns[0] + '')
const differentPatterns = randPatterns.slice(1, 1 + 100)
const differentPatternsPrecompiled = randPatterns.slice(101, 101 + 100).map(s => new RegExp(s))
const valuesToTest = randValues.slice(201, 201 + 100)
const samePattern2 = makeArray(100, () => randPatterns[202])
Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Different patterns (baseline) | | ready |
| Same pattern (should have advantage if RegExp was implemented with pattern caching) | | ready |
| Explicit caching | | ready |
| Same pattern without string modification (just for kicks) | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.