23 static bool once_is_enough;
25 std::lock_guard guard(m);
30 bacc::accumulator_set<int, bacc::stats<bacc::tag::mean, bacc::tag::min, bacc::tag::max, bacc::tag::variance>,
float> samples;
34 int test_intervals[] = {50000, 10000, 5000, 1000, 500, 100, 50, 10};
36 for(
int& interval : test_intervals) {
37 unsigned int loops = test_intervals[0]/interval;
39 for(
unsigned int i = 0; i < loops; ++i) {
40 auto start = std::chrono::high_resolution_clock::now();
43 auto end = std::chrono::high_resolution_clock::now();
44 int timer_slop = std::chrono::duration_cast<std::chrono::microseconds>(end-start).count() - interval;
53 samples(timer_slop, bacc::weight = interval/(
float)test_intervals[0]);
57 #define TIMER_STATS_FORMAT "min:${min}us max:${max}us mean:${mean}us stddev:${stddev}us"
59 ("min", bacc::min(samples))("max", bacc::max(samples)) \
60 ("mean", (int)bacc::mean(samples))("stddev", (int)sqrt(bacc::variance(samples)))
63 if(bacc::mean(samples) + sqrt(bacc::variance(samples))*2 > 250)
64 wlog(
"Checktime timer accuracy on this platform and hardware combination is poor; accuracy of subjective transaction deadline enforcement will suffer");
66 once_is_enough =
true;