Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:71.0) Gecko/20100101 Firefox/71.0
Firefox 71
Mac OS X 10.15
Desktop
4 years ago
Test name Executions per second
While Loop with cached parent_id 42964.1 Ops/sec
While Loop no caching parent_id 37076.8 Ops/sec
Using ForEach() instead of While Loop 36241.7 Ops/sec
While Loop without cache, using if/else instead of continue 42766.1 Ops/sec
While Loop without cache, using spread with assign 24169.0 Ops/sec
While Loop without cache, using spread only 63355.4 Ops/sec
For Loop version 43409.1 Ops/sec
Using ForEach() instead of While Loop, spread only 62005.6 Ops/sec
Using ForEach() instead of While Loop, spread only, no push() 60506.7 Ops/sec
Script Preparation code:
Tests:
  • While Loop with cached parent_id

  • While Loop no caching parent_id

  • Using ForEach() instead of While Loop

  • While Loop without cache, using if/else instead of continue

  • While Loop without cache, using spread with assign

  • While Loop without cache, using spread only

  • For Loop version

  • Using ForEach() instead of While Loop, spread only

  • Using ForEach() instead of While Loop, spread only, no push()


;