Quote Originally Posted by JSoftware
Robert, your unit seems usable but it has some serious bugs. Take for instance:

i := starttimer;
i2 := starttimer;
stoptimer(i);
stoptimer(i2);

this would make the procedure try to access the value in QTimers[i2] which would be QTimers[1]. This array entry does however not exist due to that we set the length of the array to 1 when we stopped timer i.
It's not a bug, it's the design purpose that I had in mind. Such as nested timers. The simple way to fix that would be to implement a timer_kill function so that you could deallocate the entry when it's not in use. The use I happened to design it for would be:
Code:
i := StartTimer;
  i2 := StartTimer;
  StopTimer(i2);
StopTimer(i);
This way you could have a timer within a loop, and one without. So you could easily find both the mean and total time, mean of execution and the total time the loop took to execute.

WILL: LOL, Yup. I figured I'd help someone who is looking for snippets.