Radium Engine
1.5.20
|
The Chrono class represents a chronometer for timing generic functions in an easy way. More...
#include <Core/Utils/Chronometer.hpp>
Public Types | |
using | MicroSeconds = long |
using | Seconds = Scalar |
Public Member Functions | |
Chrono () | |
Default constructor. | |
Chrono (const Chrono &other)=default | |
Copy constructor. | |
Chrono (Chrono &&other)=default | |
Move constructor. | |
~Chrono () | |
Destructor. | |
template<class Function , class... Args> | |
void | run (Function &&f, Args &&... args) |
Run the given void function f( args ... ) and times it. | |
template<typename ReturnType , class Function , class... Args> | |
ReturnType | run (Function &&f, Args... args) |
Run the given ReturnType function f( args ... ) and times it. | |
template<std::size_t Times, class Function , class... Args> | |
MicroSeconds | test (Function &&f, Args &&... args) |
Run the given function f( args ... ) n Times and compute the average timing. | |
MicroSeconds | elapsedMicroSeconds () const |
Return the elapsed time for last call of run in microseconds. | |
Seconds | elapsedSeconds () const |
Return the elapsed time for last call of run in seconds. | |
Chrono & | operator= (const Chrono &other)=default |
Copy assignment operator. | |
Chrono & | operator= (Chrono &&other)=default |
Move assignment operator. | |
bool | operator== (const Chrono &other) const |
Equal operator. | |
bool | operator< (const Chrono &other) const |
Less operator. | |
Protected Attributes | |
TimePoint | m_start |
VARIABLE. | |
TimePoint | m_end |
Time after running the function. | |
The Chrono class represents a chronometer for timing generic functions in an easy way.
!
Example:
void foo( foo_args ... ) { ... } some_type bar( bar_args ... ) { ... } Chrono foo_time; foo_time.run( foo, foo_args... ); Chrono bar_time; some_type bar_result = bar_time< same_type >.run( bar, foo_args... ); if( foo_time == bar_time ) { std::cout << "time is equal"; } else { if( foo_time < bar_time ) { std::cout << "foo is faster"; } else { std::cout << "bar is faster"; } }
Definition at line 38 of file Chronometer.hpp.
using Ra::Core::Utils::Chrono::MicroSeconds = long |
Definition at line 41 of file Chronometer.hpp.
using Ra::Core::Utils::Chrono::Seconds = Scalar |
Definition at line 42 of file Chronometer.hpp.
|
inline |
Default constructor.
Definition at line 46 of file Chronometer.hpp.
|
inline |
Destructor.
Definition at line 61 of file Chronometer.hpp.
|
inline |
Return the elapsed time for last call of run in microseconds.
!
Definition at line 125 of file Chronometer.hpp.
|
inline |
Return the elapsed time for last call of run in seconds.
!
Definition at line 132 of file Chronometer.hpp.
|
inline |
Less operator.
!
Definition at line 154 of file Chronometer.hpp.
Move assignment operator.
!
Copy assignment operator.
!
|
inline |
Equal operator.
!
Definition at line 147 of file Chronometer.hpp.
|
inline |
Run the given void function f( args ... ) and times it.
!
f | The function to be timed. |
args | The parameters of f. |
Function | Type of the input function (automatically deduced) |
Args | Variadic pack with function parameters |
Definition at line 71 of file Chronometer.hpp.
|
inline |
Run the given ReturnType function f( args ... ) and times it.
!
f | The function to be timed. |
args | The parameters of f. |
Times | Number of function run |
Function | Type of the input function (automatically deduced) |
Args | Variadic pack with function parameters |
Definition at line 87 of file Chronometer.hpp.
|
inline |
Run the given function f( args ... ) n Times and compute the average timing.
!
f | The function to be timed. |
args | The parameters of f. |
Times | Number of function run |
Function | Type of the input function (automatically deduced) |
Args | Variadic pack with function parameters |
Definition at line 106 of file Chronometer.hpp.
|
protected |
Time after running the function.
Definition at line 161 of file Chronometer.hpp.
|
protected |