-
Notifications
You must be signed in to change notification settings - Fork 3
/
profile.h
147 lines (123 loc) · 3.14 KB
/
profile.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#ifndef _profile_h_INCLUDED
#define _profile_h_INCLUDED
#ifndef QUIET
#include "message.h"
#include "system.h"
struct profile {
const char *name;
volatile double start;
volatile double time;
};
#define RING_PROFILES \
RING_PROFILE (fail) \
RING_PROFILE (focus) \
RING_PROFILE (probe) \
RING_PROFILE (reduce) \
RING_PROFILE (search) \
RING_PROFILE (stable) \
RING_PROFILE (vivify) \
RING_PROFILE (walk) \
\
RING_PROFILE (solve)
struct ring_profiles {
#define RING_PROFILE(NAME) struct profile NAME;
RING_PROFILES
#undef RING_PROFILE
};
#define RULER_PROFILES \
RULER_PROFILE (clone) \
RULER_PROFILE (eliminate) \
RULER_PROFILE (deduplicate) \
RULER_PROFILE (parse) \
RULER_PROFILE (solve) \
RULER_PROFILE (simplify) \
RULER_PROFILE (substitute) \
RULER_PROFILE (subsume) \
\
RULER_PROFILE (total)
struct ruler_profiles {
#define RULER_PROFILE(NAME) struct profile NAME;
RULER_PROFILES
#undef RULER_PROFILE
};
/*------------------------------------------------------------------------*/
#define profile_time current_time
#define START(OWNER, NAME) \
(verbosity < 0 ? 0.0 \
: start_profile (&OWNER->profiles.NAME, profile_time ()))
#define STOP(OWNER, NAME) \
(verbosity < 0 ? 0.0 \
: stop_profile (&OWNER->profiles.NAME, profile_time ()))
#define MODE_PROFILE \
(ring->stable ? &ring->profiles.stable : &ring->profiles.focus)
#define STOP_SEARCH() \
do { \
if (verbosity < 0) \
break; \
double t = profile_time (); \
stop_profile (MODE_PROFILE, t); \
stop_profile (&ring->profiles.search, t); \
} while (0)
#define START_SEARCH() \
do { \
if (verbosity < 0) \
break; \
double t = profile_time (); \
start_profile (&ring->profiles.search, t); \
start_profile (MODE_PROFILE, t); \
} while (0)
#define STOP_SEARCH_AND_START(NAME) \
do { \
if (verbosity < 0) \
break; \
double t = profile_time (); \
stop_profile (MODE_PROFILE, t); \
stop_profile (&ring->profiles.search, t); \
start_profile (&ring->profiles.NAME, t); \
} while (0)
#define STOP_AND_START_SEARCH(NAME) \
do { \
if (verbosity < 0) \
break; \
double t = profile_time (); \
stop_profile (&ring->profiles.NAME, t); \
start_profile (&ring->profiles.search, t); \
start_profile (MODE_PROFILE, t); \
} while (0)
#define INIT_PROFILE(OWNER, NAME) \
do { \
if (verbosity < 0) \
break; \
struct profile *profile = &OWNER->profiles.NAME; \
profile->start = -1; \
profile->name = #NAME; \
} while (0)
/*------------------------------------------------------------------------*/
double start_profile (struct profile *, double time);
double stop_profile (struct profile *, double time);
#else
struct ring_profiles {};
struct ruler_profiles {};
#define START(...) \
do { \
} while (0)
#define STOP(...) \
do { \
} while (0)
#define START_SEARCH(...) \
do { \
} while (0)
#define STOP_SEARCH(...) \
do { \
} while (0)
#define STOP_SEARCH_AND_START(...) \
do { \
} while (0)
#define STOP_AND_START_SEARCH(...) \
do { \
} while (0)
#define INIT_PROFILE(...) \
do { \
} while (0)
#endif
#endif