pytest-codspeed 4.0.0b1__tar.gz → 4.2.0b0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. {pytest_codspeed-4.0.0b1/src/pytest_codspeed.egg-info → pytest_codspeed-4.2.0b0}/PKG-INFO +46 -48
  2. pytest_codspeed-4.2.0b0/README.md +119 -0
  3. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/pyproject.toml +10 -5
  4. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/__init__.py +2 -2
  5. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/instruments/__init__.py +5 -3
  6. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/instruments/hooks/__init__.py +3 -3
  7. pytest_codspeed-4.2.0b0/src/pytest_codspeed/instruments/hooks/build.py +51 -0
  8. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/instruments/hooks/dist_instrument_hooks.pyi +7 -1
  9. pytest_codspeed-4.2.0b0/src/pytest_codspeed/instruments/hooks/instrument-hooks/dist/core.c +8638 -0
  10. pytest_codspeed-4.2.0b0/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/core.h +86 -0
  11. pytest_codspeed-4.2.0b0/src/pytest_codspeed/instruments/hooks/instrument-hooks/scripts/release.py +21 -0
  12. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/instruments/valgrind.py +5 -7
  13. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/instruments/walltime.py +12 -5
  14. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/plugin.py +10 -16
  15. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/utils.py +9 -0
  16. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0/src/pytest_codspeed.egg-info}/PKG-INFO +46 -48
  17. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed.egg-info/SOURCES.txt +1 -0
  18. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed.egg-info/requires.txt +0 -8
  19. pytest_codspeed-4.0.0b1/README.md +0 -115
  20. pytest_codspeed-4.0.0b1/src/pytest_codspeed/instruments/hooks/build.py +0 -26
  21. pytest_codspeed-4.0.0b1/src/pytest_codspeed/instruments/hooks/instrument-hooks/dist/core.c +0 -7486
  22. pytest_codspeed-4.0.0b1/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/core.h +0 -24
  23. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/LICENSE +0 -0
  24. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/setup.cfg +0 -0
  25. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/setup.py +0 -0
  26. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/config.py +0 -0
  27. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/callgrind.h +0 -0
  28. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/valgrind.h +0 -0
  29. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/zig.h +0 -0
  30. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed/py.typed +0 -0
  31. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed.egg-info/dependency_links.txt +0 -0
  32. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed.egg-info/entry_points.txt +0 -0
  33. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/src/pytest_codspeed.egg-info/top_level.txt +0 -0
  34. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/tests/test_pytest_plugin.py +0 -0
  35. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/tests/test_pytest_plugin_cpu_instrumentation.py +0 -0
  36. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/tests/test_pytest_plugin_walltime.py +0 -0
  37. {pytest_codspeed-4.0.0b1 → pytest_codspeed-4.2.0b0}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-codspeed
3
- Version: 4.0.0b1
3
+ Version: 4.2.0b0
4
4
  Summary: Pytest plugin to create CodSpeed benchmarks
5
5
  Author-email: Arthur Pastel <arthur@codspeed.io>
6
6
  License: The MIT License (MIT)
@@ -26,7 +26,7 @@ License: The MIT License (MIT)
26
26
  THE SOFTWARE.
27
27
 
28
28
  Project-URL: Homepage, https://codspeed.io/
29
- Project-URL: Documentation, https://docs.codspeed.io/
29
+ Project-URL: Documentation, https://codspeed.io/docs/reference/pytest-codspeed
30
30
  Project-URL: Source, https://github.com/CodSpeedHQ/pytest-codspeed
31
31
  Keywords: codspeed,benchmark,performance,pytest
32
32
  Classifier: Development Status :: 5 - Production/Stable
@@ -50,15 +50,9 @@ Requires-Dist: cffi>=1.17.1
50
50
  Requires-Dist: pytest>=3.8
51
51
  Requires-Dist: rich>=13.8.1
52
52
  Requires-Dist: importlib-metadata>=8.5.0; python_version < "3.10"
53
- Provides-Extra: lint
54
- Requires-Dist: mypy~=1.11.2; extra == "lint"
55
- Requires-Dist: ruff~=0.11.12; extra == "lint"
56
53
  Provides-Extra: compat
57
54
  Requires-Dist: pytest-benchmark~=5.0.0; extra == "compat"
58
55
  Requires-Dist: pytest-xdist~=3.6.1; extra == "compat"
59
- Provides-Extra: test
60
- Requires-Dist: pytest~=7.0; extra == "test"
61
- Requires-Dist: pytest-cov~=4.0.0; extra == "test"
62
56
 
63
57
  <div align="center">
64
58
  <h1>pytest-codspeed</h1>
@@ -73,11 +67,11 @@ Pytest plugin to create CodSpeed benchmarks
73
67
 
74
68
  </div>
75
69
 
76
- ## Requirements
70
+ ---
77
71
 
78
- **Python**: 3.9 and later
72
+ **Documentation**: https://codspeed.io/docs/reference/pytest-codspeed
79
73
 
80
- **pytest**: any recent version
74
+ ---
81
75
 
82
76
  ## Installation
83
77
 
@@ -89,9 +83,9 @@ pip install pytest-codspeed
89
83
 
90
84
  ### Creating benchmarks
91
85
 
92
- Creating benchmarks with `pytest-codspeed` is compatible with the standard `pytest-benchmark` API. So if you already have benchmarks written with it, you can start using `pytest-codspeed` right away.
86
+ In a nutshell, `pytest-codspeed` offers two approaches to create performance benchmarks that integrate seamlessly with your existing test suite.
93
87
 
94
- #### Marking a whole test function as a benchmark with `pytest.mark.benchmark`
88
+ Use `@pytest.mark.benchmark` to measure entire test functions automatically:
95
89
 
96
90
  ```python
97
91
  import pytest
@@ -99,55 +93,53 @@ from statistics import median
99
93
 
100
94
  @pytest.mark.benchmark
101
95
  def test_median_performance():
102
- return median([1, 2, 3, 4, 5])
96
+ input = [1, 2, 3, 4, 5]
97
+ output = sum(i**2 for i in input)
98
+ assert output == 55
103
99
  ```
104
100
 
105
- #### Benchmarking selected lines of a test function with the `benchmark` fixture
101
+ Since this measure the entire function, you might want to use the `benchmark` fixture for precise control over what code gets measured:
106
102
 
107
103
  ```python
108
- import pytest
109
- from statistics import mean
110
-
111
104
  def test_mean_performance(benchmark):
112
- # Precompute some data useful for the benchmark but that should not be
113
- # included in the benchmark time
114
105
  data = [1, 2, 3, 4, 5]
106
+ # Only the function call is measured
107
+ result = benchmark(lambda: sum(i**2 for i in data))
108
+ assert result == 55
109
+ ```
115
110
 
116
- # Benchmark the execution of the function
117
- benchmark(lambda: mean(data))
118
-
111
+ Check out the [full documentation](https://codspeed.io/docs/reference/pytest-codspeed) for more details.
119
112
 
120
- def test_mean_and_median_performance(benchmark):
121
- # Precompute some data useful for the benchmark but that should not be
122
- # included in the benchmark time
123
- data = [1, 2, 3, 4, 5]
113
+ ### Testing the benchmarks locally
124
114
 
125
- # Benchmark the execution of the function:
126
- # The `@benchmark` decorator will automatically call the function and
127
- # measure its execution
128
- @benchmark
129
- def bench():
130
- mean(data)
131
- median(data)
132
- ```
115
+ If you want to run the benchmarks tests locally, you can use the `--codspeed` pytest flag:
133
116
 
134
- ### Running benchmarks
117
+ ```sh
118
+ $ pytest tests/ --codspeed
119
+ ============================= test session starts ====================
120
+ platform darwin -- Python 3.13.0, pytest-7.4.4, pluggy-1.5.0
121
+ codspeed: 3.0.0 (enabled, mode: walltime, timer_resolution: 41.7ns)
122
+ rootdir: /home/user/codspeed-test, configfile: pytest.ini
123
+ plugins: codspeed-3.0.0
124
+ collected 1 items
135
125
 
136
- #### Testing the benchmarks locally
126
+ tests/test_sum_squares.py . [ 100%]
137
127
 
138
- If you want to run only the benchmarks tests locally, you can use the `--codspeed` pytest flag:
139
-
140
- ```shell
141
- pytest tests/ --codspeed
128
+ Benchmark Results
129
+ ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┓
130
+ ┃ Benchmark ┃ Time (best) ┃ Rel. StdDev ┃ Run time ┃ Iters ┃
131
+ ┣━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━┫
132
+ ┃test_sum_squares┃ 1,873ns ┃ 4.8% ┃ 3.00s ┃ 66,930 ┃
133
+ ┗━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━┛
134
+ =============================== 1 benchmarked ========================
135
+ =============================== 1 passed in 4.12s ====================
142
136
  ```
143
137
 
144
- > **Note:** Running `pytest-codspeed` locally will not produce any performance reporting. It's only useful for making sure that your benchmarks are working as expected. If you want to get performance reporting, you should run the benchmarks in your CI.
145
-
146
- #### In your CI
138
+ ### Running the benchmarks in your CI
147
139
 
148
140
  You can use the [CodSpeedHQ/action](https://github.com/CodSpeedHQ/action) to run the benchmarks in Github Actions and upload the results to CodSpeed.
149
141
 
150
- Example workflow:
142
+ Here is an example of a GitHub Actions workflow that runs the benchmarks and reports the results to CodSpeed on every push to the `main` branch and every pull request:
151
143
 
152
144
  ```yaml
153
145
  name: CodSpeed
@@ -156,7 +148,10 @@ on:
156
148
  push:
157
149
  branches:
158
150
  - "main" # or "master"
159
- pull_request:
151
+ pull_request: # required to have reports on PRs
152
+ # `workflow_dispatch` allows CodSpeed to trigger backtest
153
+ # performance analysis in order to generate initial data.
154
+ workflow_dispatch:
160
155
 
161
156
  jobs:
162
157
  benchmarks:
@@ -166,12 +161,15 @@ jobs:
166
161
  - uses: actions/checkout@v4
167
162
  - uses: actions/setup-python@v5
168
163
  with:
169
- python-version: "3.12"
164
+ python-version: "3.13"
165
+
170
166
  - name: Install dependencies
171
167
  run: pip install -r requirements.txt
168
+
172
169
  - name: Run benchmarks
173
- uses: CodSpeedHQ/action@v3
170
+ uses: CodSpeedHQ/action@v4
174
171
  with:
172
+ mode: instrumentation # or `walltime`
175
173
  token: ${{ secrets.CODSPEED_TOKEN }}
176
174
  run: pytest tests/ --codspeed
177
175
  ```
@@ -0,0 +1,119 @@
1
+ <div align="center">
2
+ <h1>pytest-codspeed</h1>
3
+
4
+ [![CI](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml/badge.svg)](https://github.com/CodSpeedHQ/pytest-codspeed/actions/workflows/ci.yml)
5
+ [![PyPi Version](https://img.shields.io/pypi/v/pytest-codspeed?color=%2334D058&label=pypi)](https://pypi.org/project/pytest-codspeed)
6
+ ![Python Version](https://img.shields.io/badge/python-3.9%20|%203.10%20|%203.11%20|%203.12%20|%203.13-informational.svg)
7
+ [![Discord](https://img.shields.io/badge/chat%20on-discord-7289da.svg)](https://discord.com/invite/MxpaCfKSqF)
8
+ [![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/CodSpeedHQ/pytest-codspeed)
9
+
10
+ Pytest plugin to create CodSpeed benchmarks
11
+
12
+ </div>
13
+
14
+ ---
15
+
16
+ **Documentation**: https://codspeed.io/docs/reference/pytest-codspeed
17
+
18
+ ---
19
+
20
+ ## Installation
21
+
22
+ ```shell
23
+ pip install pytest-codspeed
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Creating benchmarks
29
+
30
+ In a nutshell, `pytest-codspeed` offers two approaches to create performance benchmarks that integrate seamlessly with your existing test suite.
31
+
32
+ Use `@pytest.mark.benchmark` to measure entire test functions automatically:
33
+
34
+ ```python
35
+ import pytest
36
+ from statistics import median
37
+
38
+ @pytest.mark.benchmark
39
+ def test_median_performance():
40
+ input = [1, 2, 3, 4, 5]
41
+ output = sum(i**2 for i in input)
42
+ assert output == 55
43
+ ```
44
+
45
+ Since this measure the entire function, you might want to use the `benchmark` fixture for precise control over what code gets measured:
46
+
47
+ ```python
48
+ def test_mean_performance(benchmark):
49
+ data = [1, 2, 3, 4, 5]
50
+ # Only the function call is measured
51
+ result = benchmark(lambda: sum(i**2 for i in data))
52
+ assert result == 55
53
+ ```
54
+
55
+ Check out the [full documentation](https://codspeed.io/docs/reference/pytest-codspeed) for more details.
56
+
57
+ ### Testing the benchmarks locally
58
+
59
+ If you want to run the benchmarks tests locally, you can use the `--codspeed` pytest flag:
60
+
61
+ ```sh
62
+ $ pytest tests/ --codspeed
63
+ ============================= test session starts ====================
64
+ platform darwin -- Python 3.13.0, pytest-7.4.4, pluggy-1.5.0
65
+ codspeed: 3.0.0 (enabled, mode: walltime, timer_resolution: 41.7ns)
66
+ rootdir: /home/user/codspeed-test, configfile: pytest.ini
67
+ plugins: codspeed-3.0.0
68
+ collected 1 items
69
+
70
+ tests/test_sum_squares.py . [ 100%]
71
+
72
+ Benchmark Results
73
+ ┏━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━┓
74
+ ┃ Benchmark ┃ Time (best) ┃ Rel. StdDev ┃ Run time ┃ Iters ┃
75
+ ┣━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━┫
76
+ ┃test_sum_squares┃ 1,873ns ┃ 4.8% ┃ 3.00s ┃ 66,930 ┃
77
+ ┗━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━┛
78
+ =============================== 1 benchmarked ========================
79
+ =============================== 1 passed in 4.12s ====================
80
+ ```
81
+
82
+ ### Running the benchmarks in your CI
83
+
84
+ You can use the [CodSpeedHQ/action](https://github.com/CodSpeedHQ/action) to run the benchmarks in Github Actions and upload the results to CodSpeed.
85
+
86
+ Here is an example of a GitHub Actions workflow that runs the benchmarks and reports the results to CodSpeed on every push to the `main` branch and every pull request:
87
+
88
+ ```yaml
89
+ name: CodSpeed
90
+
91
+ on:
92
+ push:
93
+ branches:
94
+ - "main" # or "master"
95
+ pull_request: # required to have reports on PRs
96
+ # `workflow_dispatch` allows CodSpeed to trigger backtest
97
+ # performance analysis in order to generate initial data.
98
+ workflow_dispatch:
99
+
100
+ jobs:
101
+ benchmarks:
102
+ name: Run benchmarks
103
+ runs-on: ubuntu-latest
104
+ steps:
105
+ - uses: actions/checkout@v4
106
+ - uses: actions/setup-python@v5
107
+ with:
108
+ python-version: "3.13"
109
+
110
+ - name: Install dependencies
111
+ run: pip install -r requirements.txt
112
+
113
+ - name: Run benchmarks
114
+ uses: CodSpeedHQ/action@v4
115
+ with:
116
+ mode: instrumentation # or `walltime`
117
+ token: ${{ secrets.CODSPEED_TOKEN }}
118
+ run: pytest tests/ --codspeed
119
+ ```
@@ -1,6 +1,6 @@
1
1
  [project.urls]
2
2
  Homepage = "https://codspeed.io/"
3
- Documentation = "https://docs.codspeed.io/"
3
+ Documentation = "https://codspeed.io/docs/reference/pytest-codspeed"
4
4
  Source = "https://github.com/CodSpeedHQ/pytest-codspeed"
5
5
 
6
6
  [project]
@@ -37,19 +37,24 @@ dependencies = [
37
37
  ]
38
38
 
39
39
  [project.optional-dependencies]
40
- lint = ["mypy ~= 1.11.2", "ruff ~= 0.11.12"]
41
40
  compat = [
42
41
  "pytest-benchmark ~= 5.0.0",
43
42
  "pytest-xdist ~= 3.6.1",
44
43
  # "pytest-speed>=0.3.5",
45
44
  ]
46
- test = ["pytest ~= 7.0", "pytest-cov ~= 4.0.0"]
47
45
 
48
46
  [tool.uv.sources]
49
47
  pytest-codspeed = { workspace = true }
50
48
 
51
49
  [dependency-groups]
52
- dev = ["pytest-codspeed"]
50
+ dev = [
51
+ "pytest-codspeed",
52
+ "mypy ~= 1.11.2",
53
+ "ruff ~= 0.11.12",
54
+ "pytest ~= 7.0",
55
+ "pytest-cov ~= 4.0.0",
56
+ "pytest-test-groups>=1.1.0",
57
+ ]
53
58
 
54
59
  [project.entry-points]
55
60
  pytest11 = { codspeed = "pytest_codspeed.plugin" }
@@ -66,7 +71,7 @@ version = { attr = "pytest_codspeed.__version__" }
66
71
 
67
72
 
68
73
  [tool.bumpver]
69
- current_version = "4.0.0-beta1"
74
+ current_version = "4.2.0-beta"
70
75
  version_pattern = "MAJOR.MINOR.PATCH[-TAG[NUM]]"
71
76
  commit_message = "Release v{new_version} 🚀"
72
77
  tag_message = "Release v{new_version} 🚀"
@@ -1,6 +1,6 @@
1
- __version__ = "4.0.0b1"
1
+ __version__ = "4.2.0b0"
2
2
  # We also have the semver version since __version__ is not semver compliant
3
- __semver_version__ = "4.0.0-beta1"
3
+ __semver_version__ = "4.2.0-beta"
4
4
 
5
5
  from .plugin import BenchmarkFixture
6
6
 
@@ -8,11 +8,13 @@ if TYPE_CHECKING:
8
8
  from typing import Any, Callable, ClassVar, TypeVar
9
9
 
10
10
  import pytest
11
+ from typing_extensions import ParamSpec
11
12
 
12
13
  from pytest_codspeed.config import BenchmarkMarkerOptions, PedanticOptions
13
14
  from pytest_codspeed.plugin import CodSpeedConfig
14
15
 
15
16
  T = TypeVar("T")
17
+ P = ParamSpec("P")
16
18
 
17
19
 
18
20
  class Instrument(metaclass=ABCMeta):
@@ -30,9 +32,9 @@ class Instrument(metaclass=ABCMeta):
30
32
  marker_options: BenchmarkMarkerOptions,
31
33
  name: str,
32
34
  uri: str,
33
- fn: Callable[..., T],
34
- *args: tuple,
35
- **kwargs: dict[str, Any],
35
+ fn: Callable[P, T],
36
+ *args: P.args,
37
+ **kwargs: P.kwargs,
36
38
  ) -> T: ...
37
39
 
38
40
  @abstractmethod
@@ -5,11 +5,11 @@ import sys
5
5
  import warnings
6
6
  from typing import TYPE_CHECKING
7
7
 
8
+ from pytest_codspeed.utils import SUPPORTS_PERF_TRAMPOLINE
9
+
8
10
  if TYPE_CHECKING:
9
11
  from .dist_instrument_hooks import InstrumentHooksPointer, LibType
10
12
 
11
- SUPPORTS_PERF_TRAMPOLINE = sys.version_info >= (3, 12)
12
-
13
13
 
14
14
  class InstrumentHooks:
15
15
  """Zig library wrapper class providing benchmark measurement functionality."""
@@ -63,7 +63,7 @@ class InstrumentHooks:
63
63
  if pid is None:
64
64
  pid = os.getpid()
65
65
 
66
- ret = self.lib.instrument_hooks_executed_benchmark(
66
+ ret = self.lib.instrument_hooks_set_executed_benchmark(
67
67
  self.instance, pid, uri.encode("ascii")
68
68
  )
69
69
  if ret != 0:
@@ -0,0 +1,51 @@
1
+ from pathlib import Path
2
+
3
+ from cffi import FFI # type: ignore
4
+
5
+ ffibuilder = FFI()
6
+
7
+ includes_dir = Path(__file__).parent.joinpath("instrument-hooks/includes")
8
+ header_text = (includes_dir / "core.h").read_text()
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
+ """)
38
+
39
+ ffibuilder.set_source(
40
+ "pytest_codspeed.instruments.hooks.dist_instrument_hooks",
41
+ """
42
+ #include "core.h"
43
+ """,
44
+ sources=[
45
+ "src/pytest_codspeed/instruments/hooks/instrument-hooks/dist/core.c",
46
+ ],
47
+ include_dirs=[str(includes_dir)],
48
+ )
49
+
50
+ if __name__ == "__main__":
51
+ ffibuilder.compile(verbose=True)
@@ -12,7 +12,7 @@ class lib:
12
12
  @staticmethod
13
13
  def instrument_hooks_stop_benchmark(hooks: InstrumentHooksPointer) -> int: ...
14
14
  @staticmethod
15
- def instrument_hooks_executed_benchmark(
15
+ def instrument_hooks_set_executed_benchmark(
16
16
  hooks: InstrumentHooksPointer, pid: int, uri: bytes
17
17
  ) -> int: ...
18
18
  @staticmethod
@@ -20,6 +20,12 @@ class lib:
20
20
  hooks: InstrumentHooksPointer, name: bytes, version: bytes
21
21
  ) -> int: ...
22
22
  @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
23
29
  def callgrind_start_instrumentation() -> int: ...
24
30
  @staticmethod
25
31
  def callgrind_stop_instrumentation() -> int: ...