imate
C++/CUDA Reference
|
Records elasped wall time between two events. More...
#include <timer.h>
Public Member Functions | |
Timer () | |
constructor for Timer More... | |
~Timer () | |
Destructor for Timer . More... | |
void | start () |
Starts the timer. More... | |
void | stop () |
Stops the timer. More... | |
double | elapsed () const |
Returns the elapsed time in seconds. More... | |
Static Protected Member Functions | |
static double | get_wall_time () |
Returns the wall time since the epoch. More... | |
Protected Attributes | |
double | start_time |
double | stop_time |
Records elasped wall time between two events.
The measured time is the wall time, not the process time of the CPU.
Example:
Timer timer; timer.start(); // Some CPU threads here. // ... // Note, this Time measures wall time, so the sleep() time // counts toward the measured time. sleep(1); timer.stop(); double elapsed_time = timer.elapsed();
double
, and not float
to have enough precision for the subtraction of stop minus start time. However, the elapsed time outside of this class can be declared as float
.double Timer::elapsed | ( | ) | const |
Returns the elapsed time in seconds.
Definition at line 92 of file timer.cpp.
References start_time, and stop_time.
Referenced by cTraceEstimator< DataType >::c_trace_estimator().
|
staticprotected |
void Timer::start | ( | ) |
Starts the timer.
Definition at line 66 of file timer.cpp.
References get_wall_time(), and start_time.
Referenced by cTraceEstimator< DataType >::c_trace_estimator().
void Timer::stop | ( | ) |
Stops the timer.
Definition at line 79 of file timer.cpp.
References get_wall_time(), and stop_time.
Referenced by cTraceEstimator< DataType >::c_trace_estimator().
|
protected |
|
protected |