]>
Commit | Line | Data |
---|---|---|
5ba3f43e A |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <unistd.h> | |
4 | #include <sys/stat.h> | |
5 | #include <mach/mach_time.h> | |
6 | #include <sys/time.h> | |
7 | ||
8 | #include <darwintest.h> | |
9 | #include <darwintest_perf.h> | |
10 | ||
11 | T_DECL(gettimeofday_tl, "gettimeofday performance in tight loop") { | |
12 | { | |
13 | struct timeval time; | |
14 | dt_stat_time_t s = dt_stat_time_create("gettimeofday tight loop"); | |
15 | T_STAT_MEASURE_LOOP(s){ | |
16 | gettimeofday(&time, NULL); | |
17 | } | |
18 | dt_stat_finalize(s); | |
19 | } | |
20 | } | |
21 | ||
22 | extern int __gettimeofday(struct timeval *, struct timezone *); | |
23 | T_DECL(__gettimeofday_tl, "__gettimeofday performance in tight loop") { | |
24 | { | |
25 | struct timeval time; | |
26 | ||
27 | dt_stat_time_t s = dt_stat_time_create("__gettimeofday tight loop"); | |
28 | T_STAT_MEASURE_LOOP(s){ | |
29 | __gettimeofday(&time, NULL); | |
30 | } | |
31 | dt_stat_finalize(s); | |
32 | } | |
33 | } | |
34 | ||
35 | T_DECL(gettimeofday_sl, "gettimeofday performance in loop with sleep") { | |
36 | { | |
37 | struct timeval time; | |
38 | dt_stat_time_t s = dt_stat_time_create("gettimeofday loop with sleep"); | |
39 | while (!dt_stat_stable(s)) { | |
40 | T_STAT_MEASURE_BATCH(s){ | |
41 | gettimeofday(&time, NULL); | |
42 | } | |
43 | sleep(1); | |
44 | } | |
45 | dt_stat_finalize(s); | |
46 | } | |
47 | } |