cgv
Loading...
Searching...
No Matches
cgv::utils::stopwatch Class Reference

A trivial stop watch class for time measurement. More...

#include <stopwatch.h>

Public Member Functions

 stopwatch (bool silent=false)
 stopwatch (double *result, bool silent=false)
void add_time ()
double get_elapsed_time () const
 return time elpased thus far
double restart ()
 restart timer and return time elapsed until restart

Detailed Description

A trivial stop watch class for time measurement.

On Win32 the perfomance counter with a resolution of 0,313 microseconds is used, if available. If the performance counter is not available and on other systems the std::clock() function with a resolution of 0,055 milliseconds is used.

Example 1:

{ stopwatch s; dosomethingtimeconsuming(); }

The duration is written into cout.

Example 2: double d = 0.0;

{ stopwatch s(&d); dosomethingtimeconsuming(); }

See also Profiler

Definition at line 34 of file stopwatch.h.

Constructor & Destructor Documentation

◆ stopwatch() [1/2]

cgv::utils::stopwatch::stopwatch ( bool silent = false)

Definition at line 39 of file stopwatch.cxx.

◆ stopwatch() [2/2]

cgv::utils::stopwatch::stopwatch ( double * result,
bool silent = false )

Definition at line 46 of file stopwatch.cxx.

◆ ~stopwatch()

cgv::utils::stopwatch::~stopwatch ( )

Definition at line 95 of file stopwatch.cxx.

Member Function Documentation

◆ add_time()

void cgv::utils::stopwatch::add_time ( )

Definition at line 84 of file stopwatch.cxx.

◆ get_elapsed_time()

double cgv::utils::stopwatch::get_elapsed_time ( ) const

return time elpased thus far

Definition at line 68 of file stopwatch.cxx.

References get_elapsed_time().

Referenced by get_elapsed_time().

◆ restart()

double cgv::utils::stopwatch::restart ( )

restart timer and return time elapsed until restart

Definition at line 75 of file stopwatch.cxx.

References restart().

Referenced by restart().


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