File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ InstrStopNode(Instrumentation *instr, double nTuples)
95
95
if (INSTR_TIME_IS_ZERO (instr -> starttime ))
96
96
elog (ERROR , "InstrStopNode called without start" );
97
97
98
- INSTR_TIME_SET_CURRENT (endtime );
98
+ INSTR_TIME_SET_CURRENT_COARSE (endtime );
99
99
INSTR_TIME_ACCUM_DIFF (instr -> counter , endtime , instr -> starttime );
100
100
101
101
INSTR_TIME_SET_ZERO (instr -> starttime );
Original file line number Diff line number Diff line change @@ -125,6 +125,25 @@ pg_clock_gettime_ns(void)
125
125
#define INSTR_TIME_GET_NANOSEC (t ) \
126
126
((int64) (t).ticks)
127
127
128
+ #ifdef CLOCK_MONOTONIC_COARSE
129
+ /* helper for INSTR_TIME_SET_CURRENT_COARSE */
130
+ static inline instr_time
131
+ pg_clock_gettime_ns_coarse (void )
132
+ {
133
+ instr_time now ;
134
+ struct timespec tmp ;
135
+
136
+ clock_gettime (CLOCK_MONOTONIC_COARSE , & tmp );
137
+ now .ticks = tmp .tv_sec * NS_PER_S + tmp .tv_nsec ;
138
+
139
+ return now ;
140
+ }
141
+
142
+ #define INSTR_TIME_SET_CURRENT_COARSE (t ) ((t) = pg_clock_gettime_ns_coarse())
143
+ #else
144
+ #define INSTR_TIME_SET_CURRENT_COARSE (t ) INSTR_TIME_SET_CURRENT(t)
145
+ #endif
146
+
128
147
129
148
#else /* WIN32 */
130
149
@@ -159,6 +178,8 @@ GetTimerFrequency(void)
159
178
#define INSTR_TIME_GET_NANOSEC (t ) \
160
179
((int64) ((t).ticks * ((double) NS_PER_S / GetTimerFrequency())))
161
180
181
+ #define INSTR_TIME_SET_CURRENT_COARSE (t ) INSTR_TIME_SET_CURRENT(t)
182
+
162
183
#endif /* WIN32 */
163
184
164
185
@@ -172,7 +193,7 @@ GetTimerFrequency(void)
172
193
#define INSTR_TIME_SET_ZERO (t ) ((t).ticks = 0)
173
194
174
195
#define INSTR_TIME_SET_CURRENT_LAZY (t ) \
175
- (INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT (t), true : false)
196
+ (INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT_COARSE (t), true : false)
176
197
177
198
178
199
#define INSTR_TIME_ADD (x ,y ) \
You can’t perform that action at this time.
0 commit comments