Go Down

Topic: Class to help debug how long code takes (Read 1 time) previous topic - next topic

Nick Gammon

Modified above posts and downloadable library to rename timer to Timer, to be consistent with other libraries.

AWOL

Wouldn't it be better to note the start time after printing?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nick Gammon

#7
May 11, 2011, 12:56 pm Last Edit: May 11, 2011, 11:16 pm by Nick Gammon Reason: 1
I didn't understand the question, sorry.

Or maybe ...

Did you mean change:

Code: [Select]
// constructor remembers time it was constructed
ProfileTimer (const char * s) : sReason (s)
 {
   start = micros ();
   Serial.print ("Start     : ");
   Serial.println (sReason);
 };


to:

Code: [Select]
// constructor remembers time it was constructed
ProfileTimer (const char * s) : sReason (s)
 {
   Serial.print ("Start     : ");
   Serial.println (sReason);
   start = micros ();
 };


?

In which case, yes I think you are very much right.

Nick Gammon

Amended original post, and downloadable library, to incorporate your suggestion.

PaulS

I have another problem with the name of the class. The Arduino has a number of timers, and there are libraries for manipulating these timers, with Timer in the name.

Your class, while quite nice, is a bit confusing, with Timer as it's name. Perhaps the class should be called FunctionDuration or IntervalDuration, or even Duration, to make it clear that it is NOT a new class for manipulating one of the timers.

Go Up