Closed rajandangi closed 2 months ago
For your reference, here is the timing matrix I have created:
----------------------------- get_fast_modinfo inside the loop: -------------
START: Reengagement id: 314
Total users who can start this reengagement: 0
++ Time taken to get startusers: 0 seconds ++
START: Reengagement id: 317
Total users who can start this reengagement: 26449
++ Time taken to get startusers: 36 seconds ++
START: Reengagement id: 318
Total users who can start this reengagement: 26449
++ Time taken to get startusers: 41 seconds ++
START: Reengagement id: 322
Total users who can start this reengagement: 26529
++ Time taken to get startusers: 44 seconds ++
START: Reengagement id: 323
Total users who can start this reengagement: 26549
++ Time taken to get startusers: 44 seconds ++
START: Reengagement id: 324
Total users who can start this reengagement: 26556
++ Time taken to get startusers: 44 seconds ++
... used 371169 dbqueries
... used 211.66717195511 seconds
---------------- get_fast_modinfo outside the loop: ----------------
START: Reengagement id: 314
Total users who can start this reengagement: 0
++ Time taken to get startusers: 0 seconds ++
START: Reengagement id: 317
Total users who can start this reengagement: 26449
++ Time taken to get startusers: 2 seconds ++
START: Reengagement id: 318
Total users who can start this reengagement: 26449
++ Time taken to get startusers: 40 seconds ++
START: Reengagement id: 322
Total users who can start this reengagement: 26529
++ Time taken to get startusers: 42 seconds ++
START: Reengagement id: 323
Total users who can start this reengagement: 26549
++ Time taken to get startusers: 42 seconds ++
START: Reengagement id: 324
Total users who can start this reengagement: 26556
++ Time taken to get startusers: 45 seconds ++
... used 344726 dbqueries
... used 173.34275102615 seconds
--------------------- After implementing array_filter with get_fast_modinfo outside loop: ---------------------
START: Reengagement id: 314
Total users (before availability check): 0
++ Time taken to get startusers: 0 seconds ++
START: Reengagement id: 317
Total users (before availability check): 26449
++ Time taken to get startusers: 2 seconds ++
START: Reengagement id: 318
Total users (before availability check): 26449
++ Time taken to get startusers: 27 seconds ++
START: Reengagement id: 322
Total users (before availability check): 26529
++ Time taken to get startusers: 29 seconds ++
START: Reengagement id: 323
Total users (before availability check): 26549
++ Time taken to get startusers: 29 seconds ++
START: Reengagement id: 324
Total users (before availability check): 26556
++ Time taken to get startusers: 29 seconds ++
... used 344726 dbqueries
... used 120.5196211338 seconds
array_filter
to filter the startusers based on theis_available
method of theainfomod
object.startcandidates
directly instead of modifying thestartusers
array and returning it. Which makes it more efficient.