6 using clock_type=typename std::conditional<
7 std::chrono::high_resolution_clock::is_steady,
8 std::chrono::high_resolution_clock,
9 std::chrono::steady_clock>::type;
10 static std::chrono::time_point<clock_type> epoch;
12 double inithrc() { //defines our HRC epoch
13 epoch = clock_type::now();
14 return std::chrono::duration<double>(epoch.time_since_epoch()).count();
17 auto timepoint = clock_type::now(); //gets HRC timepoint
18 auto time_since_epoch = timepoint-epoch; //gets the elapsed time since the start of HRC clock
19 double seconds = std::chrono::duration<double>(time_since_epoch).count(); //converts that time into seconds(double)
22 uint64_t gethrctime_micro() {
23 auto timepoint = clock_type::now(); //gets HRC timepoint
24 auto time_since_epoch = timepoint-epoch; //gets the elapsed time since the start of HRC clock
25 auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(time_since_epoch).count(); //converts that time into microseconds(integer)