I'm currently adding a diagnostic variable to my script that only runs in diagnostic mode. It collects all the logic that's triggered by each run. It's very time consuming to manually add this diagnostic feature to my script. Is there an automated tool that's available to do that?
Yep, xdebug is great for this scenario, you can invoke the profiler and it will show you every function that was called, how long it took to run that function, how many times it was executed, etc, etc, etc. I've used it plenty of times just to find bottlenecks and to see what functions could likely use some TLC because they are taking too long.