blob: 078c4bbacf593cdafe26e43ea23febea8fecdb50 (
plain) (
tree)
|
|
#include <timer.h>
#include <unistd.h>
#include <cstdio>
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;
}
|