forked from apple-oss-distributions/xnu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgettimeofday_29192647.c
49 lines (43 loc) · 1.08 KB
/
gettimeofday_29192647.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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <mach/mach_time.h>
#include <sys/time.h>
#include <darwintest.h>
#include <darwintest_perf.h>
T_GLOBAL_META(T_META_TAG_PERF);
T_DECL(gettimeofday_tl, "gettimeofday performance in tight loop") {
{
struct timeval time;
dt_stat_time_t s = dt_stat_time_create("gettimeofday tight loop");
T_STAT_MEASURE_LOOP(s){
gettimeofday(&time, NULL);
}
dt_stat_finalize(s);
}
}
extern int __gettimeofday(struct timeval *, struct timezone *);
T_DECL(__gettimeofday_tl, "__gettimeofday performance in tight loop") {
{
struct timeval time;
dt_stat_time_t s = dt_stat_time_create("__gettimeofday tight loop");
T_STAT_MEASURE_LOOP(s){
__gettimeofday(&time, NULL);
}
dt_stat_finalize(s);
}
}
T_DECL(gettimeofday_sl, "gettimeofday performance in loop with sleep") {
{
struct timeval time;
dt_stat_time_t s = dt_stat_time_create("gettimeofday loop with sleep");
while (!dt_stat_stable(s)) {
T_STAT_MEASURE_BATCH(s){
gettimeofday(&time, NULL);
}
sleep(1);
}
dt_stat_finalize(s);
}
}