26 #include "../types.hpp"
45 #define DURATIONUNITMAP(durationtype)\
46 template<> struct duration_unit_map<durationtype>\
48 static const string unit;\
51 #define DURATIONUNITMAPINIT(durationtype,unit_string)\
52 const string duration_unit_map<durationtype>::unit = string(unit_string)
57 DURATIONUNITMAP(std::chrono::nanoseconds);
58 DURATIONUNITMAP(std::chrono::microseconds);
59 DURATIONUNITMAP(std::chrono::milliseconds);
60 DURATIONUNITMAP(std::chrono::seconds);
61 DURATIONUNITMAP(std::chrono::minutes);
62 DURATIONUNITMAP(std::chrono::hours);
114 void start() { _start = CLKT::now(); }
118 void stop() { _stop = CLKT::now(); }
124 return float64(std::chrono::duration_cast<DTYPE>(_stop-_start).count());
136 template<
typename CLKT,
typename DTYPE>
137 const string chrono_timer<CLKT,DTYPE>::name =
string(
"chrono_timer");
string unit() const
get the unit of the timer
Definition: chrono_timer.hpp:129
void start()
start the timer
Definition: chrono_timer.hpp:114
timer class using chrono
Definition: chrono_timer.hpp:98
unit map
Definition: chrono_timer.hpp:43
Definition: add_op.hpp:29
CLKT::time_point _start
start time
Definition: chrono_timer.hpp:101
float64 duration() const
get the duration as double
Definition: chrono_timer.hpp:122
chrono_timer()
default constructor
Definition: chrono_timer.hpp:110
CLKT::time_point _stop
end time
Definition: chrono_timer.hpp:102
double float64
64Bit IEEE floating point type
Definition: types/types.hpp:56
static const string name
name of the timer
Definition: chrono_timer.hpp:107
void stop()
stop the timer
Definition: chrono_timer.hpp:118
std::string string
String type.
Definition: types/types.hpp:69