Identifying rogue cases – (by that I mean a combination of circumstances that cause a normally well behaved procedure to take forever), is very simple using these profiling tools. For the sake of this example, I’m assuming you have read about profiling, downloaded and added profiling using the autoprofiler, played around with it and come up with a section of code that has a wide variance of execution times, and you want to understand which iterations are taking a long time.

Identifying rogues

Lets look at an example

Whats happening

We have identified that sometimes the section of code between our start and finish timers takes a long time to execute. We want to halt execution and debug when it happens.
First set up a cproctimer class to use.
Note that when you break execution, the timer continues so every time you look at cTimer.soFar it will have increased. If this matters, pause the timer with ctimer.pause before breaking code execution.
Another useful one would be number of iterations, as below where execution will break when the number of times we have been in this loop is 5000 or more.


Clearly this gives a powerful tool to break execution programatically if certain activities take longer than expected. See here for  more on the cproctimer class.