Camargue
Public Member Functions | Private Attributes | List of all members
CMR::Timer Class Reference

A class for recording CPU and wall clock time. More...

#include <timer.hpp>

Collaboration diagram for CMR::Timer:
Collaboration graph
[legend]

Public Member Functions

 Timer ()
 Construct unnamed timer. More...
 
 Timer (const std::string &tname)
 Construct a named timer. More...
 
 Timer (const std::string &tname, const Timer *_ratio_timer)
 Construct a named timer with ratio timer. More...
 
void start ()
 Start accumulating time at current time, resetting elapsed times. More...
 
void stop ()
 Stop accumulating times and add them to elapsed times. More...
 
void resume ()
 Start accumulating time without resetting elapsed times. More...
 
void report (bool show_cpu) const
 Reports the elapsed times and ratios if applicable. More...
 

Private Attributes

std::string timer_name
 The name of the Timer. More...
 
std::chrono::duration< double > wall_elapsed
 Elapsed wall clock or stopwatch time. More...
 
double cpu_elapsed
 Elapsed CPU time. More...
 
std::chrono::time_point< std::chrono::system_clock > wall_start
 Wall clock start time. More...
 
std::chrono::time_point< std::chrono::system_clock > wall_end
 Wall clock end time. More...
 
double cpu_start
 CPU clock start time. More...
 
double cpu_end
 CPU clock end time. More...
 
const Timerratio_timer
 For use by report to report elapsed times as ratio of other timer. More...
 

Detailed Description

A class for recording CPU and wall clock time.

Constructor & Destructor Documentation

CMR::Timer::Timer ( )

Construct unnamed timer.

CMR::Timer::Timer ( const std::string &  tname)

Construct a named timer.

CMR::Timer::Timer ( const std::string &  tname,
const Timer _ratio_timer 
)

Construct a named timer with ratio timer.

In the presence of a ratio_timer, calls to profile will report elapsed time(s) as a fraction of those from ratio_timer.

Member Function Documentation

void CMR::Timer::report ( bool  show_cpu) const

Reports the elapsed times and ratios if applicable.

If show_cpu is true, cpu_elapsed will be reported as well. If not, only wall_elapsed will be reported. Generally show_cpu should be false unless the process spawns multiple threads.

void CMR::Timer::resume ( )

Start accumulating time without resetting elapsed times.

void CMR::Timer::start ( )

Start accumulating time at current time, resetting elapsed times.

void CMR::Timer::stop ( )

Stop accumulating times and add them to elapsed times.

Member Data Documentation

double CMR::Timer::cpu_elapsed
private

Elapsed CPU time.

double CMR::Timer::cpu_end
private

CPU clock end time.

double CMR::Timer::cpu_start
private

CPU clock start time.

const Timer* CMR::Timer::ratio_timer
private

For use by report to report elapsed times as ratio of other timer.

If ratio_timer is not nullptr, then a call to report will also report wall_elapsed and cpu_elapsed as a ratio of those respective values from ratio_timer.

std::string CMR::Timer::timer_name
private

The name of the Timer.

timer_name will be used by report to identify the time(s) printed. For most nicely formatted output, keep timer_name at 20 chars or less.

std::chrono::duration<double> CMR::Timer::wall_elapsed
private

Elapsed wall clock or stopwatch time.

std::chrono::time_point<std::chrono::system_clock> CMR::Timer::wall_end
private

Wall clock end time.

std::chrono::time_point<std::chrono::system_clock> CMR::Timer::wall_start
private

Wall clock start time.


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