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
function trunc(n) {
n = +n;
if (n !== n || n === 0 || n === -Infinity || n === Infinity) {
return n;
} else if (n < 0) {
return Math.ceil(n);
} else {
return Math.floor(n);
}
}
function opMod(a, n) {
return +a % +n;
}
function truncMod(a, n) {
a = +a;
n = +n;
return a - n * trunc(a / n);
}
function floorMod(a, n) {
a = +a;
n = +n;
return a - n * Math.floor(a / n);
}
function euclidMod(a, n) {
a = +a;
n = Math.abs(+n);
return a - n * Math.floor(a / n);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
Modulo operator (truncated division) |
| ready |
Truncated division |
| ready |
Floored division |
| ready |
Euclidean division |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.