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 47353.9 Ops/sec
While Loop no caching parent_id 43586.6 Ops/sec
Using ForEach() instead of While Loop 41848.3 Ops/sec
While Loop without cache, using if/else instead of continue 50547.1 Ops/sec
While Loop without cache, using spread with assign 26750.3 Ops/sec
While Loop without cache, using spread only 62886.8 Ops/sec
For Loop version 52101.7 Ops/sec
Using ForEach() instead of While Loop, spread only 60124.4 Ops/sec
Using ForEach() instead of While Loop, spread only, no push() 60508.8 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()


;