23 #include "absl/base/internal/cycleclock.h"
28 #include "absl/base/internal/unscaledcycleclock.h"
32 namespace base_internal {
34 #if ABSL_USE_UNSCALED_CYCLECLOCK
39 #ifdef ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY
43 static constexpr
int32_t kShift = 1;
48 static constexpr
int32_t kShift = 0;
53 static constexpr
int32_t kShift = 2;
56 static constexpr
double kFrequencyScale = 1.0 / (1 << kShift);
57 static std::atomic<CycleClockSourceFunc> cycle_clock_source;
62 if (cycle_clock_source.load(std::memory_order_relaxed) ==
nullptr) {
69 return cycle_clock_source.load(std::memory_order_acquire);
75 auto fn = LoadCycleClockSource();
79 return fn() >> kShift;
83 return kFrequencyScale * base_internal::UnscaledCycleClock::Frequency();
88 cycle_clock_source.store(source, std::memory_order_release);
94 return std::chrono::duration_cast<std::chrono::nanoseconds>(