The timer object. The intention is to track all timing information used during debugging, and make this available. The interface is as simple as possible. You get a reference to the timer, and then an object can log (sending
this
) with a specific name.
A timer remembers every time step, until cleared. So you get time spans, but as well absolute start and stop times. Each object has access to many timers, each identified by a string name.
The call uses
object.toString()
as the identifier for the object making the call, so if two objects have the same result for
toString
then their timing would be aggregated.
In general, you call
start
and then, some time later, call
stop
. These calls would be made with the same name; the timer would record the start and stop time for this name.
Call
start
,...,
start
and then
stop
to record multiple time points, all ending at the same time.
Call
start
,
stop
,...,
stop
to record multiple time points, all starting at the same time.
By default, the timer formats with num, average, min, max values. It is an easy exercise to add in custom formatters, but not pressing at this time.
You can also add durations to a timer, but beware. Adding a duration is the same as
start(now - duration)
followed by
stop(now)
. If you mix
start
and
stop
calls with
duration
calls, things may get wonky.
The default formatter will also print out split times. If the timer name has the suffix
.split
then the output will contain the times in correct format.
@author parki