Skip to content

Commit f6a8a56

Browse files
committed
chore: bump instrument-hooks
1 parent 4bcadee commit f6a8a56

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

src/pytest_codspeed/instruments/hooks/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def set_executed_benchmark(self, uri: str, pid: int | None = None) -> None:
6363
if pid is None:
6464
pid = os.getpid()
6565

66-
ret = self.lib.instrument_hooks_executed_benchmark(
66+
ret = self.lib.instrument_hooks_set_executed_benchmark(
6767
self.instance, pid, uri.encode("ascii")
6868
)
6969
if ret != 0:

src/pytest_codspeed/instruments/hooks/build.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,35 @@
66

77
includes_dir = Path(__file__).parent.joinpath("instrument-hooks/includes")
88
header_text = (includes_dir / "core.h").read_text()
9-
filtered_header = "\n".join(
10-
line for line in header_text.splitlines() if not line.strip().startswith("#")
11-
)
12-
ffibuilder.cdef(filtered_header)
9+
10+
11+
# Manually copied from `instrument-hooks/includes/core.h` to avoid parsing issues
12+
ffibuilder.cdef("""
13+
typedef uint64_t *InstrumentHooks;
14+
15+
InstrumentHooks *instrument_hooks_init(void);
16+
void instrument_hooks_deinit(InstrumentHooks *);
17+
18+
bool instrument_hooks_is_instrumented(InstrumentHooks *);
19+
uint8_t instrument_hooks_start_benchmark(InstrumentHooks *);
20+
uint8_t instrument_hooks_stop_benchmark(InstrumentHooks *);
21+
uint8_t instrument_hooks_set_executed_benchmark(InstrumentHooks *, int32_t pid,
22+
const char *uri);
23+
uint8_t instrument_hooks_set_integration(InstrumentHooks *, const char *name,
24+
const char *version);
25+
26+
#define MARKER_TYPE_SAMPLE_START 0
27+
#define MARKER_TYPE_SAMPLE_END 1
28+
#define MARKER_TYPE_BENCHMARK_START 2
29+
#define MARKER_TYPE_BENCHMARK_END 3
30+
31+
uint8_t instrument_hooks_add_marker(InstrumentHooks *, uint32_t pid,
32+
uint8_t marker_type, uint64_t timestamp);
33+
uint64_t instrument_hooks_current_timestamp(void);
34+
35+
void callgrind_start_instrumentation();
36+
void callgrind_stop_instrumentation();
37+
""")
1338

1439
ffibuilder.set_source(
1540
"pytest_codspeed.instruments.hooks.dist_instrument_hooks",

src/pytest_codspeed/instruments/hooks/dist_instrument_hooks.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,20 @@ class lib:
1212
@staticmethod
1313
def instrument_hooks_stop_benchmark(hooks: InstrumentHooksPointer) -> int: ...
1414
@staticmethod
15-
def instrument_hooks_executed_benchmark(
15+
def instrument_hooks_set_executed_benchmark(
1616
hooks: InstrumentHooksPointer, pid: int, uri: bytes
1717
) -> int: ...
1818
@staticmethod
1919
def instrument_hooks_set_integration(
2020
hooks: InstrumentHooksPointer, name: bytes, version: bytes
2121
) -> int: ...
2222
@staticmethod
23+
def instrument_hooks_add_marker(
24+
hooks: InstrumentHooksPointer, pid: int, marker_type: int, timestamp: int
25+
) -> int: ...
26+
@staticmethod
27+
def instrument_hooks_current_timestamp() -> int: ...
28+
@staticmethod
2329
def callgrind_start_instrumentation() -> int: ...
2430
@staticmethod
2531
def callgrind_stop_instrumentation() -> int: ...

0 commit comments

Comments
 (0)