Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36
Chrome 78
Mac OS X 10.15.1
Desktop
4 years ago
Test name Executions per second
While Loop with cached parent_id 27182.3 Ops/sec
While Loop no caching parent_id 27500.5 Ops/sec
Using ForEach() instead of While Loop 26830.1 Ops/sec
While Loop without cache, using if/else instead of continue 27608.6 Ops/sec
While Loop without cache, using spread with assign 26854.6 Ops/sec
While Loop without cache, using spread only 260459.8 Ops/sec
For Loop version 27491.0 Ops/sec
Using ForEach() instead of While Loop, spread only 261854.0 Ops/sec
Using ForEach() instead of While Loop, spread only, no push() 255615.4 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()


;