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