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
let naiveClientIdCounter = 0;
let prefix = '';
function naiveClientId_prefix_decimals() {
if (naiveClientIdCounter >= Number.MAX_SAFE_INTEGER) {
prefix = prefix === '' ? '0' : `${parseInt(prefix, 10) + 1}`;
naiveClientIdCounter = 0;
}
return prefix + `${naiveClientIdCounter++}`;
}
function naiveClientId_prefix_hex() {
const base = 16;
if (naiveClientIdCounter >= Number.MAX_SAFE_INTEGER) {
prefix = prefix === '' ? '0' : `${(parseInt(prefix, base) + 1).toString(base)}`;
naiveClientIdCounter = 0;
}
return prefix + (naiveClientIdCounter++).toString(base);
}
function naiveClientId_prefix_b36() {
const base = 36;
if (naiveClientIdCounter >= Number.MAX_SAFE_INTEGER) {
prefix = prefix === '' ? '0' : `${(parseInt(prefix, base) + 1).toString(base)}`;
naiveClientIdCounter = 0;
}
return prefix + (naiveClientIdCounter++).toString(base);
}
function naiveClientId_decimals() {
return naiveClientIdCounter++;
}
function naiveClientId_hex() {
return (naiveClientIdCounter++).toString(16);
}
function naiveClientId_b36() {
return (naiveClientIdCounter++).toString(36);
}
naiveClientIdCounter = 0;
prefix = '';Ready to run.
| Test | Ops/sec | |
|---|---|---|
| string ID in decimals + prefix | | ready |
| string ID in hex format + prefix | | ready |
| string ID in decimals without prefix | | ready |
| string ID in hex without prefix | | ready |
| string ID in b36 without prefix | | ready |
| string ID in b36 with prefix | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.