High Precision Timer Class.
All members of SDMPerfTimer, including inherited members.
Methods| Method | Description |
|---|---|
| - (uint64_t) getTimeElapsedInMillisec | Retrieves the time elapsed after calling startTimer, resetTimer or between two consecutive getTimeElapsedInMillisec calls. |
| - (void) reset | Resets the timer. |
| - (void) start | Initializes the timer. |
The timer class should be used for accurate performance measurements. SDMPerfTimer uses low level Mach timing functions, therefore it is reliable and lightweight.
Sample usage:
// instantiate the timer and start it
SDMPerfTimer* perfTimer = [[SDMPerfTimer alloc] init];
[perfTimer start];
...
// invoke when and from wherever needed (must not be the same scope as the start or reset message)
double elapsedTime = [perfTimer getTimeElapsedInMillisec];
NSLog("Time elapsed: [f ms], [f s]", elapsedTime, (elapsedTime / 1000.f) );
// release the timer when you do not need it anymore
[perfTimer release];