84#define NS_PER_S INT64CONST(1000000000)
85#define NS_PER_MS INT64CONST(1000000)
86#define NS_PER_US INT64CONST(1000)
89#define TICKS_TO_NS_SHIFT 14
98#if defined(__x86_64__) || defined(_M_X64)
99#define PG_INSTR_TICKS_TO_NS 1
100#define PG_INSTR_TSC_CLOCK 1
102#define PG_INSTR_TICKS_TO_NS 1
103#define PG_INSTR_TSC_CLOCK 0
105#define PG_INSTR_TICKS_TO_NS 0
106#define PG_INSTR_TSC_CLOCK 0
127#if PG_INSTR_TSC_CLOCK
164#if PG_INSTR_TSC_CLOCK
180#if PG_INSTR_TSC_CLOCK
208#if defined(__darwin__) && defined(CLOCK_MONOTONIC_RAW)
209#define PG_INSTR_SYSTEM_CLOCK CLOCK_MONOTONIC_RAW
210#define PG_INSTR_SYSTEM_CLOCK_NAME "clock_gettime (CLOCK_MONOTONIC_RAW)"
211#elif defined(CLOCK_MONOTONIC)
212#define PG_INSTR_SYSTEM_CLOCK CLOCK_MONOTONIC
213#define PG_INSTR_SYSTEM_CLOCK_NAME "clock_gettime (CLOCK_MONOTONIC)"
215#define PG_INSTR_SYSTEM_CLOCK CLOCK_REALTIME
216#define PG_INSTR_SYSTEM_CLOCK_NAME "clock_gettime (CLOCK_REALTIME)"
237#define PG_INSTR_SYSTEM_CLOCK_NAME "QueryPerformanceCounter"
247 now.ticks = tmp.QuadPart;
257#if PG_INSTR_TICKS_TO_NS
301#if PG_INSTR_TICKS_TO_NS
334#if PG_INSTR_TSC_CLOCK
336#define PG_INSTR_TSC_CLOCK_NAME_FAST "RDTSC"
337#define PG_INSTR_TSC_CLOCK_NAME "RDTSCP"
419#define INSTR_TIME_IS_ZERO(t) ((t).ticks == 0)
421#define INSTR_TIME_SET_ZERO(t) ((t).ticks = 0)
423#define INSTR_TIME_SET_CURRENT_FAST(t) \
424 ((t) = pg_get_ticks_fast())
426#define INSTR_TIME_SET_CURRENT(t) \
427 ((t) = pg_get_ticks())
430#define INSTR_TIME_ADD(x,y) \
431 ((x).ticks += (y).ticks)
433#define INSTR_TIME_ADD_NANOSEC(t, n) \
434 ((t).ticks += pg_ns_to_ticks(n))
436#define INSTR_TIME_SUBTRACT(x,y) \
437 ((x).ticks -= (y).ticks)
439#define INSTR_TIME_ACCUM_DIFF(x,y,z) \
440 ((x).ticks += (y).ticks - (z).ticks)
442#define INSTR_TIME_GT(x,y) \
443 ((x).ticks > (y).ticks)
445#define INSTR_TIME_GET_NANOSEC(t) \
446 (pg_ticks_to_ns((t).ticks))
448#define INSTR_TIME_GET_DOUBLE(t) \
449 ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_S)
451#define INSTR_TIME_GET_MILLISEC(t) \
452 ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_MS)
454#define INSTR_TIME_GET_MICROSEC(t) \
455 (INSTR_TIME_GET_NANOSEC(t) / NS_PER_US)
Datum now(PG_FUNCTION_ARGS)
#define Assert(condition)
#define pg_attribute_always_inline
static pg_attribute_always_inline instr_time pg_get_ticks_fast(void)
#define TICKS_TO_NS_SHIFT
PGDLLIMPORT int timing_clock_source
#define PG_INSTR_SYSTEM_CLOCK
PGDLLIMPORT uint64 max_ticks_no_overflow
void pg_initialize_timing(void)
static instr_time pg_get_ticks_system(void)
PGDLLIMPORT bool timing_initialized
static TimingClockSourceType pg_current_timing_clock_source(void)
PGDLLIMPORT bool timing_tsc_enabled
static int64 pg_ns_to_ticks(int64 ns)
static int64 pg_ticks_to_ns(int64 ticks)
@ TIMING_CLOCK_SOURCE_SYSTEM
@ TIMING_CLOCK_SOURCE_AUTO
PGDLLIMPORT uint64 ticks_per_ns_scaled
PGDLLIMPORT int32 timing_tsc_frequency_khz
bool pg_set_timing_clock_source(TimingClockSourceType source)
static pg_attribute_always_inline instr_time pg_get_ticks(void)
static rewind_source * source