-
Notifications
You must be signed in to change notification settings - Fork 0
/
time.h
45 lines (34 loc) · 846 Bytes
/
time.h
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
#pragma once
#define attr __attribute__
#include <stdbool.h>
#include <time.h>
#include <sys/time.h>
typedef struct timespec TimeSpec;
typedef struct timeval TimeVal;
/**
* A structure that contains time and time
* delta/difference information. *_cpu are for CPU
* time, *_rt are for real time and *_wc are for
* wall-clock time.
*/
struct time_info {
clock_t begin_cpu;
clock_t end_cpu;
TimeSpec begin_rt;
TimeSpec end_rt;
TimeVal begin_wc;
TimeVal end_wc;
/* the deltas */
long double cpu;
long double wc;
long double rt;
};
typedef struct time_info TimeInfo;
#define TI_FMT \
"%.2Lfs cpu, %.2Lfs rt, %.2Lfs wc"
#define TI_FMT_PARAMS(S) \
S.cpu, S.rt, S.wc
void ti_now(TimeInfo *const ti, const bool begin)
attr((nonnull));
void ti_diff(TimeInfo *const ti)
attr((nonnull));