CVB++ 14.0
StopWatch Class Reference

Speed measurement object. More...

#include <cvb/utilities/stop_watch.hpp>

Public Member Functions

 StopWatch (StopWatchMode mode=StopWatchMode::MultiCPU)
 Create a StopWatch object. More...
 
 StopWatch (StopWatch &&other) noexcept=default
 Move constructor. More...
 
void * Handle () const noexcept
 Classic API stop watch handle. More...
 
void Start ()
 Start (or re-start) the stopwatch. More...
 
std::chrono::milliseconds TimeSpan () const
 Gets the time, that has elapsed since start (or since the construction of the object, if has not been called yet). More...
 
StopWatchMode Mode () const noexcept
 Mode for which the stop watch was created. More...
 

Static Public Member Functions

static std::unique_ptr< StopWatchCreate (StopWatchMode mode=StopWatchMode::MultiCPU)
 Create a StopWatch object. More...
 
static std::unique_ptr< StopWatchFromHandle (HandleGuard< StopWatch > &&guard, StopWatchMode mode)
 Creates a stop watch from a classic API handle. More...
 

Detailed Description

Speed measurement object.

Example:
Cvb::Utilities::StopWatch stopwatch; // start stopwatch
// Function / code to measure
auto time = stopwatch.TimeSpan(); // get measurement in milliseconds
Speed measurement object.
Definition: stop_watch.hpp:47
std::chrono::milliseconds TimeSpan() const
Gets the time, that has elapsed since start (or since the construction of the object,...
Definition: stop_watch.hpp:150
Examples
Minos/QmlMinos.

Constructor & Destructor Documentation

◆ StopWatch() [1/2]

Create a StopWatch object.

Parameters
[in]modeMode for the stop watch.
Exceptions
Anyexception derived from std::exception including CvbException.

The stop watch is automatically started after creation.

◆ StopWatch() [2/2]

StopWatch ( StopWatch &&  other)
defaultnoexcept

Move constructor.

Parameters
[in]otherOther stop watch.
Exceptions
Doesnot throw any exception.

Member Function Documentation

◆ Create()

static std::unique_ptr< StopWatch > Create ( StopWatchMode  mode = StopWatchMode::MultiCPU)
inlinestatic

Create a StopWatch object.

Parameters
[in]modeMode for the stop watch.
Returns
A pointer to the stop watch.
Exceptions
Anyexception derived from std::exception including CvbException.

The stop watch is automatically started after creation.

◆ FromHandle()

static std::unique_ptr< StopWatch > FromHandle ( HandleGuard< StopWatch > &&  guard,
StopWatchMode  mode 
)
inlinestatic

Creates a stop watch from a classic API handle.

Parameters
[in]guardLife time guard for C-API handle.
[in]modeMode the handle was created with.
Returns
The stop watch created from the classic API handle.
Exceptions
Anyexception derived from std::exception including CvbException.

The stop watch takes ownership of the handle, so you must share it before using this function.

◆ Handle()

void * Handle ( ) const
inlinenoexcept

Classic API stop watch handle.

Returns
void* Classic API handle.
Exceptions
Doesnot throw any exception.

It is normally not necessary to work with this handle.

◆ Mode()

StopWatchMode Mode ( ) const
inlinenoexcept

Mode for which the stop watch was created.

Returns
Mode of the stop watch.
Exceptions
Doesnot throw any exception.

◆ Start()

void Start ( )
inline

Start (or re-start) the stopwatch.

Exceptions
Anyexception derived from std::exception including CvbException.

This will reset the time span property to 0.0. All subsequent readouts of the time span property will give the time in milliseconds, that has elapsed since the last start or since the construction of the object.

◆ TimeSpan()

std::chrono::milliseconds TimeSpan ( ) const
inline

Gets the time, that has elapsed since start (or since the construction of the object, if has not been called yet).

Returns
Time in milliseconds.
Exceptions
Anyexception derived from std::exception including CvbException.