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 randomSmallNumber = (max) => Math.floor(Math.random() * max)
const checkIfSlidesChanged = (before, after) => {
if (before.length !== after.length) return true;
// if any slides don't match, then slides have changed
if (after.find((slide, idx) => slide !== before[idx])) return true;
return false;
};
// comparing 2 very different small arrays
const slidesAfter = [];
const slidesBefore = [];
// random small array
for (let i=0; i < randomSmallNumber(10) + 1; i++) {
slidesAfter.push(randomSmallNumber(30));
slidesBefore.push(randomSmallNumber(30));
}
// short circuit 10% of the time
if (randomSmallNumber(9) === 1) {
slidesBefore.push(randomSmallNumber(30));
}
// comparing 2 small arrays with only a single difference
const similarSlidesBefore = [...slidesBefore];
const similarSlidesAfter = [...slidesBefore];
const idx = randomSmallNumber(similarSlidesBefore.length - 1);
similarSlidesBefore[idx] = randomSmallNumber(30);
Ready to run.
Test | Ops/sec | |
---|---|---|
JSON - Very Different Arrays |
| ready |
Iteration - Very Different Arrays |
| ready |
JSON - Very Similar Arrays |
| ready |
Iteration - Very Similar Arrays |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.