ARTS  2.3.1285(git:92a29ea9-dirty)
Timings Class Reference

Timings Class. More...

#include <timings.h>

Public Member Functions

 Timings ()
 Simple Constructor. More...
 
Index add_timer (String name)
 Add timer. More...
 
Numeric get_time ()
 Get Wall Time. More...
 
void mark (Index i)
 Start/Stop Timings. More...
 

Private Attributes

Index ntimers
 
Index nrunning
 
Numeric total_time
 
Numeric stamp
 
std::vector< bool > running
 
std::vector< Numerictimes
 
std::vector< Numericstamps
 
std::vector< Stringnames
 

Friends

std::ostream & operator<< (std::ostream &os, const Timings &timer)
 Print timing results. More...
 

Detailed Description

Timings Class.

Simple class that handles a variable number of timers and computes the total time. The Timings class uses the OMP library to measure the runtime and therefore only works correctly if OMP is available.

Definition at line 24 of file timings.h.

Constructor & Destructor Documentation

◆ Timings()

Timings::Timings ( )
inline

Simple Constructor.

Constructs a Timings object without any timers.

Definition at line 32 of file timings.h.

References nrunning, ntimers, stamp, and total_time.

Member Function Documentation

◆ add_timer()

Index Timings::add_timer ( String  name)
inline

Add timer.

Add timer with given name to Timings object. The name is used in the timer output.

Parameters
[in]nameThe name of the time used in the timer output.

Definition at line 46 of file timings.h.

References names, ntimers, running, stamps, and times.

◆ get_time()

Numeric Timings::get_time ( )
inline

Get Wall Time.

Returns the current wall time computed using omp_get_wtime(). If no OpenMP library is available, the functions return 0.0.

Returns
The current wall time if an OpenMP implementation is available, 0.0 otherwise.

Definition at line 64 of file timings.h.

Referenced by mark().

◆ mark()

void Timings::mark ( Index  i)
inline

Start/Stop Timings.

Starts or stops the timer with the given index. The indices of the timers reflect the order in which the timers have been added to the Timings object starting with 0 for the first timer. If the given timer is not running currently, it is started. If it is running, it is stopped and the passed time added to the total time of the timer.

Definition at line 80 of file timings.h.

References get_time(), i, nrunning, ntimers, running, stamp, stamps, times, and total_time.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Timings timer 
)
friend

Print timing results.

Prints the timing results to the given output stream.

Parameters
osThe output stream to write the timin results to.
timerThe Timings object.
Returns
The output stream.

Definition at line 18 of file timings.cc.

Member Data Documentation

◆ names

std::vector<String> Timings::names
private

Definition at line 110 of file timings.h.

Referenced by add_timer(), and operator<<().

◆ nrunning

Index Timings::nrunning
private

Definition at line 106 of file timings.h.

Referenced by mark(), and Timings().

◆ ntimers

Index Timings::ntimers
private

Definition at line 106 of file timings.h.

Referenced by add_timer(), mark(), and Timings().

◆ running

std::vector<bool> Timings::running
private

Definition at line 108 of file timings.h.

Referenced by add_timer(), and mark().

◆ stamp

Numeric Timings::stamp
private

Definition at line 107 of file timings.h.

Referenced by mark(), and Timings().

◆ stamps

std::vector<Numeric> Timings::stamps
private

Definition at line 109 of file timings.h.

Referenced by add_timer(), and mark().

◆ times

std::vector<Numeric> Timings::times
private

Definition at line 109 of file timings.h.

Referenced by add_timer(), mark(), and operator<<().

◆ total_time

Numeric Timings::total_time
private

Definition at line 107 of file timings.h.

Referenced by mark(), operator<<(), and Timings().


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