GCC Code Coverage Report


Directory: src/
File: src/standalone/instr_time.h
Date: 2026-09-30 11:11:31
Exec Total Coverage
Lines: 4 4 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2026 Tiger Data, Inc.
3 * Licensed under the PostgreSQL License. See LICENSE for details.
4 *
5 * vs_instr_time.h - Monotonic timing for build phase measurements
6 *
7 * The build logs phase durations using PostgreSQL's instr_time. In a PG build
8 * that's portability/instr_time.h; in standalone we provide the small subset
9 * the build uses (set/subtract/get-millis) over clock_gettime, so the shared
10 * timing code is unchanged.
11 */
12
13 #ifndef VS_INSTR_TIME_H
14 #define VS_INSTR_TIME_H
15
16 #include <stdint.h>
17 #include <time.h>
18
19 typedef struct instr_time
20 {
21 int64_t ticks; /* nanoseconds */
22 } instr_time;
23
24 static inline void
25 656 vs_instr_now(instr_time *t)
26 {
27 struct timespec ts;
28
29 656 clock_gettime(CLOCK_MONOTONIC, &ts);
30 656 t->ticks = (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
31 656 }
32
33 #define INSTR_TIME_SET_CURRENT(t) vs_instr_now(&(t))
34 #define INSTR_TIME_SUBTRACT(x, y) ((x).ticks -= (y).ticks)
35 #define INSTR_TIME_GET_MILLISEC(t) ((double)(t).ticks / 1e6)
36
37 #endif /* VS_INSTR_TIME_H */
38