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>
var ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
var divmod = function(val, base) {
return [~~ (val / base), val % base];
};
var encodeSplice = function(n, alphabet) {
var r = [],
_divmod, b = alphabet.length;
while (n > 0) {
_divmod = divmod(n, b);
r.splice(0, 0, alphabet[_divmod[1]]);
n = _divmod[0];
}
return r.join('');
};
var encodeReverse = function(n, alphabet) {
var r = [],
_divmod, b = alphabet.length;
while (n > 0) {
_divmod = divmod(n, b);
r.push(alphabet[_divmod[1]]);
n = _divmod[0];
}
return r.reverse().join('');
};
var decode = function(s, alphabet) {
var n = 0,
i = 0,
b = alphabet.length,
slen = s.length;
for (; i < slen; i++) {
n = (n * b) + alphabet.indexOf(s[i]);
}
return n;
};
</script>
Ready to run.
Test | Ops/sec | |
---|---|---|
Encode Splice |
| ready |
Encode Reverse |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.