NEST main@caf0ae8
 
Loading...
Searching...
No Matches
nest::timers::StopwatchTimer< clock_type > Class Template Reference

This class represents a single timer which measures the execution time of a single thread for a given clock type. More...

#include <stopwatch.h>

Public Member Functions

 StopwatchTimer ()
 Creates a stopwatch that is not running.
 
void start ()
 Starts or resumes the stopwatch, if it is not running already.
 
void stop ()
 Stops the stopwatch, if it is not stopped already.
 
double elapsed (timeunit_t timeunit=timeunit_t::SECONDS) const
 Returns the time elapsed between the start and stop of the stopwatch in the given unit.
 
void reset ()
 Resets the stopwatch.
 
void print (const std::string &msg="", timeunit_t timeunit=timeunit_t::SECONDS, std::ostream &os=std::cout) const
 This method prints out the currently elapsed time.
 

Static Private Member Functions

static size_t get_current_time ()
 Returns current time of clock_type in nanoseconds.
 

Private Attributes

size_t beg_
 clock (in ns) at which timer was last started
 
size_t end_
 clock (in ns) at which timer was last stopped (invariant: end_ >= beg_)
 
size_t prev_elapsed_
 accumulated time of all start-stop intervals since last reset
 
bool is_running_
 true between start() and stop()
 

Detailed Description

template<clockid_t clock_type>
class nest::timers::StopwatchTimer< clock_type >

This class represents a single timer which measures the execution time of a single thread for a given clock type.

Typical clocks are monotonic wall-time clocks or clocks just measuring cpu time.

Constructor & Destructor Documentation

◆ StopwatchTimer()

template<clockid_t clock_type>
nest::timers::StopwatchTimer< clock_type >::StopwatchTimer ( )
inline

Creates a stopwatch that is not running.

References nest::timers::StopwatchTimer< clock_type >::reset().

Here is the call graph for this function:

Member Function Documentation

◆ elapsed()

template<clockid_t clock_type>
double nest::timers::StopwatchTimer< clock_type >::elapsed ( timeunit_t  timeunit = timeunit_t::SECONDS) const
inline

Returns the time elapsed between the start and stop of the stopwatch in the given unit.

If the stopwatch is running, it returns the time from start until now. If the stopwatch has run previously, the previous runtime is added. If you want only the last measurement, you have to reset the timer, before stating the measurement. Does not change the running state.

◆ get_current_time()

template<clockid_t clock_type>
size_t nest::timers::StopwatchTimer< clock_type >::get_current_time ( )
inlinestaticprivate

Returns current time of clock_type in nanoseconds.

References nest::timers::SECONDS.

◆ print()

template<clockid_t clock_type>
void nest::timers::StopwatchTimer< clock_type >::print ( const std::string &  msg = "",
timeunit_t  timeunit = timeunit_t::SECONDS,
std::ostream &  os = std::cout 
) const
inline

This method prints out the currently elapsed time.

References nest::timers::DAYS, nest::timers::HOURS, nest::timers::MICROSEC, nest::timers::MILLISEC, nest::timers::MINUTES, nest::timers::NANOSEC, and nest::timers::SECONDS.

Referenced by nest::timers::operator<<().

Here is the caller graph for this function:

◆ reset()

template<clockid_t clock_type>
void nest::timers::StopwatchTimer< clock_type >::reset ( )
inline

Resets the stopwatch.

Referenced by nest::timers::StopwatchTimer< clock_type >::StopwatchTimer().

Here is the caller graph for this function:

◆ start()

template<clockid_t clock_type>
void nest::timers::StopwatchTimer< clock_type >::start ( )
inline

Starts or resumes the stopwatch, if it is not running already.

◆ stop()

template<clockid_t clock_type>
void nest::timers::StopwatchTimer< clock_type >::stop ( )
inline

Stops the stopwatch, if it is not stopped already.

Member Data Documentation

◆ beg_

template<clockid_t clock_type>
size_t nest::timers::StopwatchTimer< clock_type >::beg_
private

clock (in ns) at which timer was last started

◆ end_

template<clockid_t clock_type>
size_t nest::timers::StopwatchTimer< clock_type >::end_
private

clock (in ns) at which timer was last stopped (invariant: end_ >= beg_)

◆ is_running_

template<clockid_t clock_type>
bool nest::timers::StopwatchTimer< clock_type >::is_running_
private

true between start() and stop()

◆ prev_elapsed_

template<clockid_t clock_type>
size_t nest::timers::StopwatchTimer< clock_type >::prev_elapsed_
private

accumulated time of all start-stop intervals since last reset


The documentation for this class was generated from the following file: