Loading...
Searching...
No Matches
terra::util::Timer Class Reference

Timer supporting RAII scope or manual stop. More...

#include <timer.hpp>

Public Member Functions

 Timer (const std::string &n)
 Constructor - starts the timer.
 
void stop ()
 Stop the timer and record elapsed time.
 
 ~Timer ()
 Destructor stops timer if still running.
 

Detailed Description

Timer supporting RAII scope or manual stop.

Starts timer on construction.

Automatically adds timing to TimerTree's singleton instance. See TimerTree for details on how to export the timings.

Example usage: scoped

{
Timer t("compute"); // scoped timer - starts here
// do computation
} // timer ends here - writes result to TimerTree::instance()
Timer supporting RAII scope or manual stop.
Definition timer.hpp:270

Example usage: stop explicitly

{
Timer t("compute"); // scoped timer - starts here
// do computation
t.stop() // timer ends here - writes result to TimerTree::instance()
// do something that is not included in timing
}

Constructor & Destructor Documentation

◆ Timer()

terra::util::Timer::Timer ( const std::string &  n)
inlineexplicit

Constructor - starts the timer.

Parameters
nTimer name

◆ ~Timer()

terra::util::Timer::~Timer ( )
inline

Destructor stops timer if still running.

Can be used instead of stopping manually.

Member Function Documentation

◆ stop()

void terra::util::Timer::stop ( )
inline

Stop the timer and record elapsed time.

Can be safely called twice - does not do anything on second call.


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