PostgreSQL Source Code  git master
instr_time.h File Reference
#include <time.h>
Include dependency graph for instr_time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PG_INSTR_CLOCK   CLOCK_REALTIME
 
#define INSTR_TIME_IS_ZERO(t)   ((t).tv_nsec == 0 && (t).tv_sec == 0)
 
#define INSTR_TIME_SET_ZERO(t)   ((t).tv_sec = 0, (t).tv_nsec = 0)
 
#define INSTR_TIME_SET_CURRENT(t)   ((void) clock_gettime(PG_INSTR_CLOCK, &(t)))
 
#define INSTR_TIME_ADD(x, y)
 
#define INSTR_TIME_SUBTRACT(x, y)
 
#define INSTR_TIME_ACCUM_DIFF(x, y, z)
 
#define INSTR_TIME_GET_DOUBLE(t)    (((double) (t).tv_sec) + ((double) (t).tv_nsec) / 1000000000.0)
 
#define INSTR_TIME_GET_MILLISEC(t)    (((double) (t).tv_sec * 1000.0) + ((double) (t).tv_nsec) / 1000000.0)
 
#define INSTR_TIME_GET_MICROSEC(t)    (((uint64) (t).tv_sec * (uint64) 1000000) + (uint64) ((t).tv_nsec / 1000))
 
#define INSTR_TIME_SET_CURRENT_LAZY(t)    (INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)
 

Typedefs

typedef struct timespec instr_time
 

Macro Definition Documentation

◆ INSTR_TIME_ACCUM_DIFF

#define INSTR_TIME_ACCUM_DIFF (   x,
  y,
 
)
Value:
do { \
(x).tv_sec += (y).tv_sec - (z).tv_sec; \
(x).tv_nsec += (y).tv_nsec - (z).tv_nsec; \
/* Normalize after each add to avoid overflow/underflow of tv_nsec */ \
while ((x).tv_nsec < 0) \
{ \
(x).tv_nsec += 1000000000; \
(x).tv_sec--; \
} \
while ((x).tv_nsec >= 1000000000) \
{ \
(x).tv_nsec -= 1000000000; \
(x).tv_sec++; \
} \
} while (0)
int y
Definition: isn.c:72
int x
Definition: isn.c:71

Definition at line 115 of file instr_time.h.

◆ INSTR_TIME_ADD

#define INSTR_TIME_ADD (   x,
  y 
)
Value:
do { \
(x).tv_sec += (y).tv_sec; \
(x).tv_nsec += (y).tv_nsec; \
/* Normalize */ \
while ((x).tv_nsec >= 1000000000) \
{ \
(x).tv_nsec -= 1000000000; \
(x).tv_sec++; \
} \
} while (0)

Definition at line 91 of file instr_time.h.

◆ INSTR_TIME_GET_DOUBLE

#define INSTR_TIME_GET_DOUBLE (   t)     (((double) (t).tv_sec) + ((double) (t).tv_nsec) / 1000000000.0)

Definition at line 132 of file instr_time.h.

◆ INSTR_TIME_GET_MICROSEC

#define INSTR_TIME_GET_MICROSEC (   t)     (((uint64) (t).tv_sec * (uint64) 1000000) + (uint64) ((t).tv_nsec / 1000))

Definition at line 138 of file instr_time.h.

◆ INSTR_TIME_GET_MILLISEC

#define INSTR_TIME_GET_MILLISEC (   t)     (((double) (t).tv_sec * 1000.0) + ((double) (t).tv_nsec) / 1000000.0)

Definition at line 135 of file instr_time.h.

◆ INSTR_TIME_IS_ZERO

#define INSTR_TIME_IS_ZERO (   t)    ((t).tv_nsec == 0 && (t).tv_sec == 0)

Definition at line 85 of file instr_time.h.

◆ INSTR_TIME_SET_CURRENT

#define INSTR_TIME_SET_CURRENT (   t)    ((void) clock_gettime(PG_INSTR_CLOCK, &(t)))

Definition at line 89 of file instr_time.h.

◆ INSTR_TIME_SET_CURRENT_LAZY

#define INSTR_TIME_SET_CURRENT_LAZY (   t)     (INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)

Definition at line 184 of file instr_time.h.

◆ INSTR_TIME_SET_ZERO

#define INSTR_TIME_SET_ZERO (   t)    ((t).tv_sec = 0, (t).tv_nsec = 0)

Definition at line 87 of file instr_time.h.

◆ INSTR_TIME_SUBTRACT

#define INSTR_TIME_SUBTRACT (   x,
  y 
)
Value:
do { \
(x).tv_sec -= (y).tv_sec; \
(x).tv_nsec -= (y).tv_nsec; \
/* Normalize */ \
while ((x).tv_nsec < 0) \
{ \
(x).tv_nsec += 1000000000; \
(x).tv_sec--; \
} \
} while (0)

Definition at line 103 of file instr_time.h.

◆ PG_INSTR_CLOCK

#define PG_INSTR_CLOCK   CLOCK_REALTIME

Definition at line 80 of file instr_time.h.

Typedef Documentation

◆ instr_time

typedef struct timespec instr_time

Definition at line 1 of file instr_time.h.