Script Preparation code:
Tests:
  • Basic for loop

  • For loop but caching the length

  • While loop that imitates a for loop

  • While loop that imitates a for loop caching len

  • While loop in reverse simplifying the test

  • While looping by popping values

  • for ... in loop

  • for ... in loop with integer test

  • For loop testing on existence rather than lengt

  • For loop testing on existence plus array lookup

  • For testing on existence rather than length array

  • For reference

  • Array.forEach() native implementation.

  • For reference against forEach()

Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results
  • Test case name Result
    Basic for loop
    For loop but caching the length
    While loop that imitates a for loop
    While loop that imitates a for loop caching len
    While loop in reverse simplifying the test
    While looping by popping values
    for ... in loop
    for ... in loop with integer test
    For loop testing on existence rather than lengt
    For loop testing on existence plus array lookup
    For testing on existence rather than length array
    For reference
    Array.forEach() native implementation.
    For reference against forEach()

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.113 Safari/537.36
Chrome 53 on Windows
View result in a separate tab
Test name Executions per second
Basic for loop 7268.3 Ops/sec
For loop but caching the length 605072.3 Ops/sec
While loop that imitates a for loop 6503.2 Ops/sec
While loop that imitates a for loop caching len 570308.4 Ops/sec
While loop in reverse simplifying the test 647350.1 Ops/sec
While looping by popping values 6684267.0 Ops/sec
for ... in loop 3997473.8 Ops/sec
for ... in loop with integer test 4071390.2 Ops/sec
For loop testing on existence rather than lengt 6892458.0 Ops/sec
For loop testing on existence plus array lookup 7364022.0 Ops/sec
For testing on existence rather than length array 7183270.5 Ops/sec
For reference 8238255.0 Ops/sec
Array.forEach() native implementation. 6457470.0 Ops/sec
For reference against forEach() 7420539.0 Ops/sec