Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
Chrome 84
Linux
Desktop
4 years ago
Test name Executions per second
For loop, basic 2134.0 Ops/sec
While loop, basic 2198.2 Ops/sec
For loop, cached (inside for statement) 2927.5 Ops/sec
For loop, cached (outside for statement) 3325.2 Ops/sec
For loop, i-- (caching inside for loop) 3298.9 Ops/sec
For loop, i-- (caching outside for loop) 3220.6 Ops/sec
While loop, cached 2067.5 Ops/sec
While loop, i-- 2114.1 Ops/sec
map 3484.8 Ops/sec
forEach 3860.6 Ops/sec
Script Preparation code:
Tests:
  • For loop, basic

  • While loop, basic

  • For loop, cached (inside for statement)

  • For loop, cached (outside for statement)

  • For loop, i-- (caching inside for loop)

  • For loop, i-- (caching outside for loop)

  • While loop, cached

  • While loop, i--

  • map

  • forEach