Utilities
Loading...
Searching...
No Matches
timing.h File Reference
#include <chrono>
#include <stack>
Include dependency graph for timing.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

using Clock = std::chrono::high_resolution_clock
 
using TPoint = std::chrono::time_point< Clock >
 

Functions

auto tic ()
 
double toc (TPoint const &t_b=MyStopWatch.top())
 

Variables

std::stack< TPointMyStopWatch
 starting time of stopwatch
 

Typedef Documentation

◆ Clock

using Clock = std::chrono::high_resolution_clock

Definition at line 9 of file timing.h.

◆ TPoint

using TPoint = std::chrono::time_point<Clock>

Definition at line 10 of file timing.h.

Function Documentation

◆ tic()

auto tic ( )
inline

Starts stopwatch timer. Use as

tic(); myfunction(...) ; double tsec = toc();
#define vector
double toc(TPoint const &t_b=MyStopWatch.top())
Definition timing.h:43
auto tic()
Definition timing.h:24

The timining can be nested and the recent time point is stored on top of the stack.

Returns
recent time point
See also
toc

Definition at line 24 of file timing.h.

Here is the caller graph for this function:

◆ toc()

double toc ( TPoint const t_b = MyStopWatch.top())
inline

Returns the elapsed time from stopwatch.

The time point from top of the stack is used if time point t_b is not passed as input parameter. Use as

tic(); myfunction(...) ; double tsec = toc();

or as

auto t_b = tic(); myfunction(...) ; double tsec = toc(t_b);

The last option is to be used in the case of non-nested but overlapping time measurements.

Parameters
[in]t_bstart time of some stop watch
Returns
elapsed time in seconds.

Definition at line 43 of file timing.h.

Here is the caller graph for this function:

Variable Documentation

◆ MyStopWatch

std::stack<TPoint> MyStopWatch
inline

starting time of stopwatch

Definition at line 14 of file timing.h.