Run details:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Safari/605.1.15
Safari 13
Mac OS X 10.15.1
Desktop
4 years ago
Test name Executions per second
While Loop with cached parent_id 52898.8 Ops/sec
While Loop no caching parent_id 50179.9 Ops/sec
Using ForEach() instead of While Loop 42828.0 Ops/sec
While Loop without cache, using if/else instead of continue 55152.8 Ops/sec
While Loop without cache, using spread with assign 13271.3 Ops/sec
While Loop without cache, using spread only 18173.0 Ops/sec
For Loop version 54903.4 Ops/sec
Using ForEach() instead of While Loop, spread only 17077.0 Ops/sec
Using ForEach() instead of While Loop, spread only, no push() 16756.5 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()


;