The Timer represents a simulation stopwatch.
More...
#include "pinspec/src/Timer.h"
|
| Timer () |
| Timer class constructor. More...
|
|
virtual | ~Timer () |
| Default Timer destructor.
|
|
void | start () |
| Starts the Timer in a similar fashion to starting a stopwatch.
|
|
void | stop () |
| Stops the timer in a similar fashion to stopping a stopwatch.
|
|
void | restart () |
| Restarts the timer. More...
|
|
void | reset () |
| Resets the timer in a similar fashion to resetting a stopwatch.
|
|
void | recordSplit (const char *msg) |
| Records a message corresponding to a given time recorded by the timer. More...
|
|
double | getTime () |
| Returns the amount of time elapsed from start to stop of the timer. More...
|
|
double | diff (timespec start, timespec end) |
| Helper function which computes the time between the values of two timespec structs. More...
|
|
void | printSplits () |
| Prints the Timer's splits to the console. More...
|
|
The Timer represents a simulation stopwatch.
The timer class is for profiling code. It outputs running time in seconds but has resolution of microseconds on OSX and nanoseconds on Linux machines.
Timer class constructor.
Sets the default elapsed time to 0.0 and the stopwatch running attribute to false.
double Timer::diff |
( |
timespec |
start, |
|
|
timespec |
end |
|
) |
| |
Helper function which computes the time between the values of two timespec structs.
- Parameters
-
start | the start time timespec struct |
end | the end time timespec struct |
double Timer::getTime |
( |
| ) |
|
Returns the amount of time elapsed from start to stop of the timer.
If the timer is currently runnning, returns the time from the timer start to the present time.
- Returns
- the elapsed time
void Timer::printSplits |
( |
| ) |
|
Prints the Timer's splits to the console.
This method will loop through all of the Timer's splits and print a formatted message string (80 characters in length) to the console with the message and the time corresponding to that message
void Timer::recordSplit |
( |
const char * |
msg | ) |
|
Records a message corresponding to a given time recorded by the timer.
When this method is called it assumes that the timer has been stopped and has the current time for the process corresponding to the message.
- Parameters
-
msg | a msg corresponding to this timer split |
Restarts the timer.
The elapsed time will accumulate along with the previous time(s) the timer was running. If the timer was already running, this function does nothing.
double Timer::_elapsed_time |
|
protected |
The elapsed time between start and stop for a split
timespec Timer::_end_time |
|
protected |
The end time of a timer split
Boolean representing whether or not the time is presently running
timespec Timer::_start_time |
|
protected |
The start time of a timer split
std::vector< std::pair<double, const char*> > Timer::_timer_splits |
|
protected |
A container of times corresponding to messages for each split
The documentation for this class was generated from the following files:
- pinspec/src/Timer.h
- pinspec/src/Timer.cpp