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 2141.7 Ops/sec
While loop, basic 1947.4 Ops/sec
For loop, cached (inside for statement) 3358.3 Ops/sec
For loop, cached (outside for statement) 3380.4 Ops/sec
For loop, i-- (caching inside for loop) 3274.3 Ops/sec
For loop, i-- (caching outside for loop) 3453.2 Ops/sec
While loop, cached 3416.6 Ops/sec
While loop, i-- 3225.3 Ops/sec
map 5619.3 Ops/sec
forEach 5487.1 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