Route ampif77 and ampif90 through ampiCC, factoring out duplicated code
[charm.git] / src / conv-core / hrctimer.C
bloba172108eee81fd5294750956849011c96284ac7f
1 #include <chrono>
2 #include <type_traits>
3 #include "hrctimer.h"
4 #include <ratio>
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();
16 double gethrctime() {
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)
20   return seconds;
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)
26   return microseconds;