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 2075.3 Ops/sec
While loop, basic 1873.6 Ops/sec
For loop, cached (inside for statement) 2952.9 Ops/sec
For loop, cached (outside for statement) 3099.4 Ops/sec
For loop, i-- (caching inside for loop) 3034.8 Ops/sec
For loop, i-- (caching outside for loop) 3032.0 Ops/sec
While loop, cached 3078.5 Ops/sec
While loop, i-- 3216.6 Ops/sec
map 4469.5 Ops/sec
forEach 5158.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