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
188#if PG_INSTR_TSC_CLOCK
216#if defined(__darwin__) && defined(CLOCK_MONOTONIC_RAW)
217#define PG_INSTR_SYSTEM_CLOCK CLOCK_MONOTONIC_RAW
218#define PG_INSTR_SYSTEM_CLOCK_NAME "clock_gettime (CLOCK_MONOTONIC_RAW)"
219#elif defined(CLOCK_MONOTONIC)
220#define PG_INSTR_SYSTEM_CLOCK CLOCK_MONOTONIC
221#define PG_INSTR_SYSTEM_CLOCK_NAME "clock_gettime (CLOCK_MONOTONIC)"
223#define PG_INSTR_SYSTEM_CLOCK CLOCK_REALTIME
224#define PG_INSTR_SYSTEM_CLOCK_NAME "clock_gettime (CLOCK_REALTIME)"
245#define PG_INSTR_SYSTEM_CLOCK_NAME "QueryPerformanceCounter"
255 now.ticks = tmp.QuadPart;
265#if PG_INSTR_TICKS_TO_NS
309#if PG_INSTR_TICKS_TO_NS
342#if PG_INSTR_TSC_CLOCK
344#define PG_INSTR_TSC_CLOCK_NAME_FAST "RDTSC"
345#define PG_INSTR_TSC_CLOCK_NAME "RDTSCP"
427#define INSTR_TIME_IS_ZERO(t) ((t).ticks == 0)
429#define INSTR_TIME_SET_ZERO(t) ((t).ticks = 0)
431#define INSTR_TIME_SET_CURRENT_FAST(t) \
432 ((t) = pg_get_ticks_fast())
434#define INSTR_TIME_SET_CURRENT(t) \
435 ((t) = pg_get_ticks())
438#define INSTR_TIME_ADD(x,y) \
439 ((x).ticks += (y).ticks)
441#define INSTR_TIME_ADD_NANOSEC(t, n) \
442 ((t).ticks += pg_ns_to_ticks(n))
444#define INSTR_TIME_SUBTRACT(x,y) \
445 ((x).ticks -= (y).ticks)
447#define INSTR_TIME_ACCUM_DIFF(x,y,z) \
448 ((x).ticks += (y).ticks - (z).ticks)
450#define INSTR_TIME_GT(x,y) \
451 ((x).ticks > (y).ticks)
453#define INSTR_TIME_GET_NANOSEC(t) \
454 (pg_ticks_to_ns((t).ticks))
456#define INSTR_TIME_GET_DOUBLE(t) \
457 ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_S)
459#define INSTR_TIME_GET_MILLISEC(t) \
460 ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_MS)
462#define INSTR_TIME_GET_MICROSEC(t) \
463 (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