blob: 5ac169c6f9ea92955076c827d793e7fc54b31779 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <timer.h>
#include <unistd.h>
#include <cstdio>
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;
}
|