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
"how many decimal digits hath 𝑛 ∈ ℕ" "Math.ceil(Math.log(𝑛)) or String(𝑛).length" "which is faster" "nani"
var logTenDofN = n => Math.ceil(Math.log10(n));
// only works if JS doesn't sciencify the string
// representation for large values (X.XXXe+X)
var strLenDofN = n => String(n).length;
var digitsOfN;
const L = 10e20;
function test () {
let 𝑛 = 100;
while ((𝑛 *= 1.19) < L) digitsOfN(𝑛);
}
Ready to run.
Test | Ops/sec | |
---|---|---|
digits of n using `Math.ceil(Math.log10(𝑛))` |
| ready |
digits of n using `String(𝑛).length` |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.