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
var x=1234567890.123456789
// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLogLookup
var logTable256 = function (){
var logTable256=[0,0]
for (var i = 2; i < 256; i++)
logTable256[i] = 1 + logTable256[Math.floor(i / 2)]
return logTable256
}()
function log2(x) {
var v = Math.floor(x)
var t, tt
if (tt = v >> 16)
return (t = tt >> 8) ? 24 + logTable256[t] : 16 + logTable256[tt]
else
return (t = v >> 8) ? 8 + logTable256[t] : logTable256[v]
}
var floor=Math.floor,log=Math.log,ln2=Math.LN2
var u = new Uint32Array(2);
var d = new Float64Array(u.buffer);
Ready to run.
Test | Ops/sec | |
---|---|---|
Math.log(x)/Math.LN2 |
| ready |
Math.log(x)/Math.LN2 via local refs |
| ready |
integer log2 |
| ready |
inline integer log2 |
| ready |
inline integer log2; floor deferred |
| ready |
uin32 float conversion |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.