NEST
2.6.0,not_revisioned_source_dir@0
|
#include <stopwatch.h>
Public Types | |
enum | { MICROSEC = (timeunit_t)1, MILLISEC = MICROSEC * 1000, SECONDS = MILLISEC * 1000, MINUTES = SECONDS * 60, HOURS = MINUTES * 60, DAYS = HOURS * 24 } |
typedef size_t | timestamp_t |
typedef size_t | timeunit_t |
Public Member Functions | |
Stopwatch () | |
Creates a stopwatch that is not running. More... | |
void | start () |
Starts or resumes the stopwatch, if it is not running already. More... | |
void | stop () |
Stops the stopwatch, if it is not stopped already. More... | |
bool | isRunning () const |
Returns, whether the stopwatch is running. More... | |
double | elapsed (timeunit_t timeunit=SECONDS) const |
Returns the time elapsed between the start and stop of the stopwatch. More... | |
timestamp_t | elapsed_timestamp () const |
Returns the time elapsed between the start and stop of the stopwatch. More... | |
void | reset () |
Resets the stopwatch. More... | |
void | print (const char *msg="", timeunit_t timeunit=SECONDS, std::ostream &os=std::cout) const |
This method prints out the currently elapsed time. More... | |
Static Public Member Functions | |
static bool | correct_timeunit (timeunit_t t) |
Static Private Member Functions | |
static timestamp_t | get_timestamp () |
Returns current time in microseconds since EPOCH. More... | |
Private Attributes | |
timestamp_t | _beg |
timestamp_t | _end |
size_t | _prev_elapsed |
bool | _running |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Stopwatch &stopwatch) |
Convenient method for writing time in seconds to some ostream. More... | |
typedef size_t nest::Stopwatch::timestamp_t |
typedef size_t nest::Stopwatch::timeunit_t |
|
inline |
Creates a stopwatch that is not running.
References reset().
|
inlinestatic |
|
inline |
Returns the time elapsed between the start and stop of the stopwatch.
If it is running, it returns the time from start until now. If the stopwatch is run previously, the previous runtime is added. If you want only the last measurment, you have to reset the timer, before stating the measurment. Does not change the running state.
References assert(), correct_timeunit(), and elapsed_timestamp().
Referenced by print(), nest::Communicator::time_communicate(), nest::Communicator::time_communicate_alltoall(), nest::Communicator::time_communicate_alltoallv(), nest::Communicator::time_communicate_offgrid(), and nest::Communicator::time_communicatev().
|
inline |
Returns the time elapsed between the start and stop of the stopwatch.
If it is running, it returns the time from start until now. If the stopwatch is run previously, the previous runtime is added. If you want only the last measurment, you have to reset the timer, before stating the measurment. Does not change the running state. In contrast to Stopwatch::elapsed(), only the timestamp is returned, that is the number if microseconds as an integer.
References _beg, _end, _prev_elapsed, get_timestamp(), and isRunning().
Referenced by elapsed().
|
inlinestaticprivate |
Returns current time in microseconds since EPOCH.
References SECONDS.
Referenced by elapsed_timestamp(), start(), and stop().
|
inline |
Returns, whether the stopwatch is running.
References _running.
Referenced by elapsed_timestamp(), start(), and stop().
|
inline |
This method prints out the currently elapsed time.
References _beg, _end, _prev_elapsed, _running, assert(), correct_timeunit(), DAYS, numerics::e, elapsed(), HOURS, MICROSEC, MILLISEC, MINUTES, and SECONDS.
Referenced by nest::operator<<().
|
inline |
Resets the stopwatch.
References _beg, _end, _prev_elapsed, and _running.
Referenced by Stopwatch().
|
inline |
Starts or resumes the stopwatch, if it is not running already.
References _beg, _end, _prev_elapsed, _running, get_timestamp(), and isRunning().
Referenced by nest::Communicator::time_communicate(), nest::Communicator::time_communicate_alltoall(), nest::Communicator::time_communicate_alltoallv(), nest::Communicator::time_communicate_offgrid(), and nest::Communicator::time_communicatev().
|
inline |
Stops the stopwatch, if it is not stopped already.
References _end, _running, get_timestamp(), and isRunning().
Referenced by nest::Communicator::time_communicate(), nest::Communicator::time_communicate_alltoall(), nest::Communicator::time_communicate_alltoallv(), nest::Communicator::time_communicate_offgrid(), and nest::Communicator::time_communicatev().
|
friend |
Convenient method for writing time in seconds to some ostream.
|
private |
Referenced by elapsed_timestamp(), print(), reset(), and start().
|
private |
Referenced by elapsed_timestamp(), print(), reset(), start(), and stop().
|
private |
Referenced by elapsed_timestamp(), print(), reset(), and start().
|
private |
Referenced by isRunning(), print(), reset(), start(), and stop().