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
https://stackoverflow.com/questions/78362457/is-there-a-general-approach-for-optimizing-bitwise-expressions-that-distinguish < trying some of the solutions here, along with some more naive solutions.
const N = 60000;
const cases = new Array(N).fill(0).map(() =>
Math.floor(Math.random() * 8)
);
function run (test) {
let guys = 0;
for (const x of cases) if (test(x)) guys++;
console.log(`got ${guys} / ${N} guys`);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
chained boolean `||` (reference implementation) |
| ready |
switch |
| ready |
smallbrain test 1 |
| ready |
1st answer |
| ready |
2nd answer |
| ready |
3rd answer |
| ready |
LUT |
| ready |
set |
| ready |
object, lol |
| ready |
TRYHARD object |
| ready |
map? |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.