77#define NS_PER_S INT64CONST(1000000000)
78#define NS_PER_MS INT64CONST(1000000)
79#define NS_PER_US INT64CONST(1000)
101#if defined(__darwin__) && defined(CLOCK_MONOTONIC_RAW)
102#define PG_INSTR_CLOCK CLOCK_MONOTONIC_RAW
103#elif defined(CLOCK_MONOTONIC)
104#define PG_INSTR_CLOCK CLOCK_MONOTONIC
106#define PG_INSTR_CLOCK CLOCK_REALTIME
122#define INSTR_TIME_SET_CURRENT(t) \
123 ((t) = pg_clock_gettime_ns())
125#define INSTR_TIME_GET_NANOSEC(t) \
142 now.ticks = tmp.QuadPart;
153 return (
double) f.QuadPart;
156#define INSTR_TIME_SET_CURRENT(t) \
157 ((t) = pg_query_performance_counter())
159#define INSTR_TIME_GET_NANOSEC(t) \
160 ((int64) ((t).ticks * ((double) NS_PER_S / GetTimerFrequency())))
169#define INSTR_TIME_IS_ZERO(t) ((t).ticks == 0)
171#define INSTR_TIME_SET_ZERO(t) ((t).ticks = 0)
174#define INSTR_TIME_ADD(x,y) \
175 ((x).ticks += (y).ticks)
177#define INSTR_TIME_SUBTRACT(x,y) \
178 ((x).ticks -= (y).ticks)
180#define INSTR_TIME_ACCUM_DIFF(x,y,z) \
181 ((x).ticks += (y).ticks - (z).ticks)
183#define INSTR_TIME_GT(x,y) \
184 ((x).ticks > (y).ticks)
186#define INSTR_TIME_GET_DOUBLE(t) \
187 ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_S)
189#define INSTR_TIME_GET_MILLISEC(t) \
190 ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_MS)
192#define INSTR_TIME_GET_MICROSEC(t) \
193 (INSTR_TIME_GET_NANOSEC(t) / NS_PER_US)
Datum now(PG_FUNCTION_ARGS)
static instr_time pg_clock_gettime_ns(void)