Open liamdon opened 11 months ago
The lookup table approach is really neat, but after running some benchmarks it looks like we can get a ~10-15x speedup by using the built-in Math.clz32()
Math.clz32()
let n = 2; for (let i = 0; i < 16; i++) { getLSBIndex(n); n *= 2; }
Math.clz32() Browser support
The lookup table approach is really neat, but after running some benchmarks it looks like we can get a ~10-15x speedup by using the built-in
Math.clz32()
Benchmark
Chrome 119
Safari 17.9
Math.clz32() Browser support