File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,15 @@ BENCHMARK(CODE_TO_TIME);
3636
3737namespace benchmark {
3838
39- using clock = std::chrono::high_resolution_clock;
39+ // On many systems, the high_resolution_clock offers no better resolution than the steady_clock.
40+ // If that's the case, prefer the steady_clock.
41+ struct best_clock {
42+ using hi_res_clock = std::chrono::high_resolution_clock;
43+ using steady_clock = std::chrono::steady_clock;
44+ static constexpr bool steady_is_high_res = std::ratio_less_equal<steady_clock::period, hi_res_clock::period>::value;
45+ using type = std::conditional<steady_is_high_res, steady_clock, hi_res_clock>::type;
46+ };
47+ using clock = best_clock::type;
4048 using time_point = clock::time_point;
4149 using duration = clock::duration;
4250
You can’t perform that action at this time.
0 commit comments