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