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
/**
* Pros:
* Cons:
* - Slow
* - Not uniform (there are more items in slot 0|0 than any other slot)
*/
function ParseIntHash(x, y) {
x = parseInt(x) - (parseInt(x) % 8);
y = parseInt(y) - (parseInt(y) % 8);
return x + "|" + y;
}
/**
* Pros:
* - Fast
* Cons:
* - Non-uniform (there are more items in slot 0|0 than any other slot)
*/
function TruncIntHash(x, y) {
x = Math.trunc(x) - (Math.trunc(x) % 8);
y = Math.trunc(y) - (Math.trunc(y) % 8);
return x + "|" + y;
}
/**
* Pros:
* - Fast
* - Uniform (same number of items in every slot)
* Cons:
*/
function BestBoiHash(x, y) {
return (x >> 3) + "|" + (y >> 3);
}
var X = Math.random() * 1000 - 500;
var Y = Math.random() * 1000 - 500;
var RESULT = 0;
Ready to run.
Test | Ops/sec | |
---|---|---|
Parse Integer |
| ready |
Trunc Integer |
| ready |
Best Boi Hash |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.