-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.c
67 lines (48 loc) · 1.19 KB
/
example.c
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* example.c
A file showing timequick usage, and to
run some quick tests.
*/
#include "timequick.h"
#include <stdlib.h>
#include <unistd.h>
int main(void) {
tq_start(NULL);
sleep(1);
tq_stop("default");
tq_set_unit(tq_MILLISECONDS);
tq_start(NULL);
sleep(1);
tq_stop("milliseconds");
tq_set_unit(tq_MICROSECONDS);
tq_start(NULL);
sleep(1);
tq_stop("microseconds");
tq_set_unit(tq_NANOSECONDS);
tq_start(NULL);
sleep(1);
tq_stop("nanoseconds");
tq_set_unit(tq_SECONDS);
tq_start(NULL);
sleep(1);
tq_stop("seconds");
/* For nesting. */
tq_start("Outer");
for (int i = 0; i < 3; ++i) {
tq_start("Inner");
sleep(1);
tq_stop("Inner");
}
tq_stop("Outer");
}
/*
Example output:
tq_stop: default: 1.000094s
tq_stop: milliseconds: 1000.102404ms
tq_stop: microseconds: 1000063.659000us
tq_stop: nanoseconds: 1000159071.000000ns
tq_stop: seconds: 1.000173s
tq_stop: Inner: 1.000108s
tq_stop: Inner: 1.000164s
tq_stop: Inner: 1.000163s
tq_stop: Outer: 3.000533s
*/