3#include <Core/Utils/Timer.hpp>
41 using MicroSeconds = long;
42 using Seconds = Scalar;
70 template <
class Function,
class... Args>
71 inline void run( Function&& f, Args&&... args ) {
72 m_start = Clock::now();
86 template <
typename ReturnType,
class Function,
class... Args>
87 inline ReturnType
run( Function&& f, Args... args ) {
90 m_start = Clock::now();
91 ReturnType res = f( args... );
105 template <
std::size_t Times,
class Function,
class... Args>
106 inline MicroSeconds
test( Function&& f, Args&&... args ) {
107 MicroSeconds avg = 0;
109 m_start = Clock::now();
111 m_end = Clock::now();
112 avg += getIntervalMicro( m_start, m_end );
115 m_start = Clock::now();
132 inline Seconds
elapsedSeconds()
const {
return getIntervalSeconds( m_start, m_end ); }
The Chrono class represents a chronometer for timing generic functions in an easy way.
Chrono & operator=(const Chrono &other)=default
Copy assignment operator.
ReturnType run(Function &&f, Args... args)
Run the given ReturnType function f( args ... ) and times it.
bool operator<(const Chrono &other) const
Less operator.
TimePoint m_end
Time after running the function.
bool operator==(const Chrono &other) const
Equal operator.
MicroSeconds test(Function &&f, Args &&... args)
Run the given function f( args ... ) n Times and compute the average timing.
Chrono(const Chrono &other)=default
Copy constructor.
TimePoint m_start
VARIABLE.
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.
void run(Function &&f, Args &&... args)
Run the given void function f( args ... ) and times it.
Chrono(Chrono &&other)=default
Move constructor.
Chrono & operator=(Chrono &&other)=default
Move assignment operator.
Chrono()
Default constructor.
hepler function to manage enum as underlying types in VariableSet