In this case you're actually just benchmarking the console.log and seeing slight variations in the time that takes. It doesn't take anywhere near ~6ms just to run a for loop once! Using my little benchmarkjs-powered tool (but you can use any benchmarking library), we can get more precise numbers:
132,000,000 ops/sec > for-let (19.3x)
114,000,000 ops/sec > forEach (16.6x)
95,000,000 ops/sec > for of (13.8x)
6,860,000 ops/sec > for in (1x)
Benches: 4
Fastest: for-let
Elapsed: 21.8s
In this case you're actually just benchmarking the console.log and seeing slight variations in the time that takes. It doesn't take anywhere near ~6ms just to run a for loop once! Using my little
benchmarkjs
-powered tool (but you can use any benchmarking library), we can get more precise numbers:Source: gist.github.com/connor4312/07da143...
Ok , I will try it.