#include #include #include int main() { timer::timer t; const auto kShowTime = [&t]() { std::fprintf(stderr, "usec=%f msec=%f sec=%f\n", t.as_usec(), t.as_msec(), t.as_sec()); }; { puts("Sleep 100ms"); const timer::scoped_timer kS{t}; usleep(100 * 1000); } kShowTime(); { puts("Sleep 500ms"); const timer::scoped_timer kS{t}; usleep(500 * 1000); } kShowTime(); return 0; }