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
<script>
function mod_a(n, d) {
return n - (d * Math.floor(n / d));
}
function mod_b(n, d) {
var q = ~~(n / d);
if (n < 0) q = q - 1;
return n - (d * q);
}
function mod_c(n, d) {
var q = ~~(n / d);
(n < 0) ? --q : q;
return n - (d * q);
}
function mod_d(n, d) {
var remain = n % d;
return remain >= 0 ? remain : remain + d;
};
function mod_e(n, d) {
return ((n % d) + d) % d;
}
function modlk (num, mod) {
if (mod & (mod - 1) === 0 && mod !== 0) {
return num & (mod - 1);
}
return num < 0 ? ((num % mod) + mod) % mod : num % mod;
}
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
mod_a |
| ready |
mod_b |
| ready |
mod_c |
| ready |
mod_d |
| ready |
mod_e |
| ready |
mod_a (non-int) |
| ready |
mod_b (non-int) |
| ready |
mod_c (non-int) |
| ready |
mod_d (non-int) |
| ready |
mod_e (non-int) |
| ready |
modlk (non-int) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.