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.

Data Structures

struct  instr_time
 

Macros

#define NS_PER_S   INT64CONST(1000000000)
 
#define NS_PER_MS   INT64CONST(1000000)
 
#define NS_PER_US   INT64CONST(1000)
 
#define PG_INSTR_CLOCK   CLOCK_REALTIME
 
#define INSTR_TIME_SET_CURRENT(t)    ((t) = pg_clock_gettime_ns())
 
#define INSTR_TIME_GET_NANOSEC(t)    ((int64) (t).ticks)
 
#define INSTR_TIME_IS_ZERO(t)   ((t).ticks == 0)
 
#define INSTR_TIME_SET_ZERO(t)   ((t).ticks = 0)
 
#define INSTR_TIME_SET_CURRENT_LAZY(t)    (INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)
 
#define INSTR_TIME_ADD(x, y)    ((x).ticks += (y).ticks)
 
#define INSTR_TIME_SUBTRACT(x, y)    ((x).ticks -= (y).ticks)
 
#define INSTR_TIME_ACCUM_DIFF(x, y, z)    ((x).ticks += (y).ticks - (z).ticks)
 
#define INSTR_TIME_GET_DOUBLE(t)    ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_S)
 
#define INSTR_TIME_GET_MILLISEC(t)    ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_MS)
 
#define INSTR_TIME_GET_MICROSEC(t)    (INSTR_TIME_GET_NANOSEC(t) / NS_PER_US)
 

Typedefs

typedef struct instr_time instr_time
 

Functions

static instr_time pg_clock_gettime_ns (void)
 

Macro Definition Documentation

◆ INSTR_TIME_ACCUM_DIFF

#define INSTR_TIME_ACCUM_DIFF (   x,
  y,
 
)     ((x).ticks += (y).ticks - (z).ticks)

Definition at line 184 of file instr_time.h.

◆ INSTR_TIME_ADD

#define INSTR_TIME_ADD (   x,
  y 
)     ((x).ticks += (y).ticks)

Definition at line 178 of file instr_time.h.

◆ INSTR_TIME_GET_DOUBLE

#define INSTR_TIME_GET_DOUBLE (   t)     ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_S)

Definition at line 188 of file instr_time.h.

◆ INSTR_TIME_GET_MICROSEC

#define INSTR_TIME_GET_MICROSEC (   t)     (INSTR_TIME_GET_NANOSEC(t) / NS_PER_US)

Definition at line 194 of file instr_time.h.

◆ INSTR_TIME_GET_MILLISEC

#define INSTR_TIME_GET_MILLISEC (   t)     ((double) INSTR_TIME_GET_NANOSEC(t) / NS_PER_MS)

Definition at line 191 of file instr_time.h.

◆ INSTR_TIME_GET_NANOSEC

#define INSTR_TIME_GET_NANOSEC (   t)     ((int64) (t).ticks)

Definition at line 125 of file instr_time.h.

◆ INSTR_TIME_IS_ZERO

#define INSTR_TIME_IS_ZERO (   t)    ((t).ticks == 0)

Definition at line 169 of file instr_time.h.

◆ INSTR_TIME_SET_CURRENT

#define INSTR_TIME_SET_CURRENT (   t)     ((t) = pg_clock_gettime_ns())

Definition at line 122 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 174 of file instr_time.h.

◆ INSTR_TIME_SET_ZERO

#define INSTR_TIME_SET_ZERO (   t)    ((t).ticks = 0)

Definition at line 172 of file instr_time.h.

◆ INSTR_TIME_SUBTRACT

#define INSTR_TIME_SUBTRACT (   x,
  y 
)     ((x).ticks -= (y).ticks)

Definition at line 181 of file instr_time.h.

◆ NS_PER_MS

#define NS_PER_MS   INT64CONST(1000000)

Definition at line 78 of file instr_time.h.

◆ NS_PER_S

#define NS_PER_S   INT64CONST(1000000000)

Definition at line 77 of file instr_time.h.

◆ NS_PER_US

#define NS_PER_US   INT64CONST(1000)

Definition at line 79 of file instr_time.h.

◆ PG_INSTR_CLOCK

#define PG_INSTR_CLOCK   CLOCK_REALTIME

Definition at line 106 of file instr_time.h.

Typedef Documentation

◆ instr_time

typedef struct instr_time instr_time

Function Documentation

◆ pg_clock_gettime_ns()

static instr_time pg_clock_gettime_ns ( void  )
inlinestatic

Definition at line 111 of file instr_time.h.

112 {
113  instr_time now;
114  struct timespec tmp;
115 
116  clock_gettime(PG_INSTR_CLOCK, &tmp);
117  now.ticks = tmp.tv_sec * NS_PER_S + tmp.tv_nsec;
118 
119  return now;
120 }
Datum now(PG_FUNCTION_ARGS)
Definition: timestamp.c:1608
#define NS_PER_S
Definition: instr_time.h:77
#define PG_INSTR_CLOCK
Definition: instr_time.h:106

References now(), NS_PER_S, and PG_INSTR_CLOCK.