pytest-codspeed 3.1.2__tar.gz → 3.3.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.
- {pytest_codspeed-3.1.2/src/pytest_codspeed.egg-info → pytest_codspeed-3.3.0b0}/PKG-INFO +2 -2
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/pyproject.toml +7 -1
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/setup.py +3 -5
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed/__init__.py +2 -2
- pytest_codspeed-3.3.0b0/src/pytest_codspeed/instruments/hooks/__init__.py +83 -0
- pytest_codspeed-3.3.0b0/src/pytest_codspeed/instruments/hooks/build.py +26 -0
- pytest_codspeed-3.3.0b0/src/pytest_codspeed/instruments/hooks/instrument-hooks/dist/core.c +7486 -0
- pytest_codspeed-3.3.0b0/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/callgrind.h +124 -0
- pytest_codspeed-3.3.0b0/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/core.h +24 -0
- pytest_codspeed-3.3.0b0/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/valgrind.h +7168 -0
- pytest_codspeed-3.3.0b0/src/pytest_codspeed/instruments/hooks/instrument-hooks/includes/zig.h +4209 -0
- pytest_codspeed-3.1.2/src/pytest_codspeed/instruments/valgrind/__init__.py → pytest_codspeed-3.3.0b0/src/pytest_codspeed/instruments/valgrind.py +16 -19
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed/instruments/walltime.py +49 -17
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed/plugin.py +2 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0/src/pytest_codspeed.egg-info}/PKG-INFO +2 -2
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed.egg-info/SOURCES.txt +8 -6
- pytest_codspeed-3.1.2/src/pytest_codspeed/instruments/valgrind/_wrapper/__init__.py +0 -15
- pytest_codspeed-3.1.2/src/pytest_codspeed/instruments/valgrind/_wrapper/build.py +0 -19
- pytest_codspeed-3.1.2/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.c +0 -25
- pytest_codspeed-3.1.2/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.h +0 -6
- pytest_codspeed-3.1.2/src/pytest_codspeed/instruments/valgrind/_wrapper/wrapper.pyi +0 -13
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/LICENSE +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/README.md +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/setup.cfg +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed/instruments/__init__.py +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed/py.typed +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed/utils.py +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed.egg-info/dependency_links.txt +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed.egg-info/entry_points.txt +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed.egg-info/requires.txt +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/src/pytest_codspeed.egg-info/top_level.txt +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/tests/test_pytest_plugin.py +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/tests/test_pytest_plugin_cpu_instrumentation.py +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/tests/test_pytest_plugin_walltime.py +0 -0
- {pytest_codspeed-3.1.2 → pytest_codspeed-3.3.0b0}/tests/test_utils.py +0 -0
|
@@ -45,6 +45,12 @@ compat = [
|
|
|
45
45
|
]
|
|
46
46
|
test = ["pytest ~= 7.0", "pytest-cov ~= 4.0.0"]
|
|
47
47
|
|
|
48
|
+
[tool.uv.sources]
|
|
49
|
+
pytest-codspeed = { workspace = true }
|
|
50
|
+
|
|
51
|
+
[dependency-groups]
|
|
52
|
+
dev = ["pytest-codspeed"]
|
|
53
|
+
|
|
48
54
|
[project.entry-points]
|
|
49
55
|
pytest11 = { codspeed = "pytest_codspeed.plugin" }
|
|
50
56
|
|
|
@@ -60,7 +66,7 @@ version = { attr = "pytest_codspeed.__version__" }
|
|
|
60
66
|
|
|
61
67
|
|
|
62
68
|
[tool.bumpver]
|
|
63
|
-
current_version = "3.
|
|
69
|
+
current_version = "3.3.0-beta"
|
|
64
70
|
version_pattern = "MAJOR.MINOR.PATCH[-TAG[NUM]]"
|
|
65
71
|
commit_message = "Release v{new_version} 🚀"
|
|
66
72
|
tag_message = "Release v{new_version} 🚀"
|
|
@@ -5,9 +5,7 @@ from pathlib import Path
|
|
|
5
5
|
|
|
6
6
|
from setuptools import setup
|
|
7
7
|
|
|
8
|
-
build_path = (
|
|
9
|
-
Path(__file__).parent / "src/pytest_codspeed/instruments/valgrind/_wrapper/build.py"
|
|
10
|
-
)
|
|
8
|
+
build_path = Path(__file__).parent / "src/pytest_codspeed/instruments/hooks/build.py"
|
|
11
9
|
|
|
12
10
|
spec = importlib.util.spec_from_file_location("build", build_path)
|
|
13
11
|
assert spec is not None, "The spec should be initialized"
|
|
@@ -52,8 +50,8 @@ print(
|
|
|
52
50
|
setup(
|
|
53
51
|
package_data={
|
|
54
52
|
"pytest_codspeed": [
|
|
55
|
-
"instruments/
|
|
56
|
-
"instruments/
|
|
53
|
+
"instruments/hooks/instrument-hooks/includes/*.h",
|
|
54
|
+
"instruments/hooks/instrument-hooks/dist/*.c",
|
|
57
55
|
]
|
|
58
56
|
},
|
|
59
57
|
ext_modules=(
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from .dist_instrument_hooks import lib as LibType
|
|
9
|
+
|
|
10
|
+
SUPPORTS_PERF_TRAMPOLINE = sys.version_info >= (3, 12)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class InstrumentHooks:
|
|
14
|
+
"""Zig library wrapper class providing benchmark measurement functionality."""
|
|
15
|
+
|
|
16
|
+
lib: LibType
|
|
17
|
+
instance: int
|
|
18
|
+
|
|
19
|
+
def __init__(self) -> None:
|
|
20
|
+
if os.environ.get("CODSPEED_ENV") is None:
|
|
21
|
+
raise RuntimeError(
|
|
22
|
+
"Can't run benchmarks outside of CodSpeed environment."
|
|
23
|
+
"Please set the CODSPEED_ENV environment variable."
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
from .dist_instrument_hooks import lib # type: ignore
|
|
28
|
+
except ImportError as e:
|
|
29
|
+
raise RuntimeError(f"Failed to load instrument hooks library: {e}") from e
|
|
30
|
+
|
|
31
|
+
instance = lib.instrument_hooks_init()
|
|
32
|
+
if instance == 0:
|
|
33
|
+
raise RuntimeError("Failed to initialize CodSpeed instrumentation library.")
|
|
34
|
+
|
|
35
|
+
if SUPPORTS_PERF_TRAMPOLINE:
|
|
36
|
+
sys.activate_stack_trampoline("perf") # type: ignore
|
|
37
|
+
|
|
38
|
+
self.lib = lib
|
|
39
|
+
self.instance = instance
|
|
40
|
+
|
|
41
|
+
def __del__(self):
|
|
42
|
+
if hasattr(self, "lib") and hasattr(self, "instance"):
|
|
43
|
+
self.lib.instrument_hooks_deinit(self.instance)
|
|
44
|
+
|
|
45
|
+
def start_benchmark(self) -> None:
|
|
46
|
+
"""Start a new benchmark measurement."""
|
|
47
|
+
ret = self.lib.instrument_hooks_start_benchmark(self.instance)
|
|
48
|
+
if ret != 0:
|
|
49
|
+
raise RuntimeError("Failed to start benchmark measurement")
|
|
50
|
+
|
|
51
|
+
def stop_benchmark(self) -> None:
|
|
52
|
+
"""Stop the current benchmark measurement."""
|
|
53
|
+
ret = self.lib.instrument_hooks_stop_benchmark(self.instance)
|
|
54
|
+
if ret != 0:
|
|
55
|
+
raise RuntimeError("Failed to stop benchmark measurement")
|
|
56
|
+
|
|
57
|
+
def set_executed_benchmark(self, uri: str, pid: int | None = None) -> None:
|
|
58
|
+
"""Set the executed benchmark URI and process ID.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
uri: The benchmark URI string identifier
|
|
62
|
+
pid: Optional process ID (defaults to current process)
|
|
63
|
+
"""
|
|
64
|
+
if pid is None:
|
|
65
|
+
pid = os.getpid()
|
|
66
|
+
|
|
67
|
+
ret = self.lib.instrument_hooks_executed_benchmark(
|
|
68
|
+
self.instance, pid, uri.encode("ascii")
|
|
69
|
+
)
|
|
70
|
+
if ret != 0:
|
|
71
|
+
raise RuntimeError("Failed to set executed benchmark")
|
|
72
|
+
|
|
73
|
+
def set_integration(self, name: str, version: str) -> None:
|
|
74
|
+
"""Set the integration name and version."""
|
|
75
|
+
ret = self.lib.instrument_hooks_set_integration(
|
|
76
|
+
self.instance, name.encode("ascii"), version.encode("ascii")
|
|
77
|
+
)
|
|
78
|
+
if ret != 0:
|
|
79
|
+
raise RuntimeError("Failed to set integration name and version")
|
|
80
|
+
|
|
81
|
+
def is_instrumented(self) -> bool:
|
|
82
|
+
"""Check if instrumentation is active."""
|
|
83
|
+
return self.lib.instrument_hooks_is_instrumented(self.instance)
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
filtered_header = "\n".join(
|
|
10
|
+
line for line in header_text.splitlines() if not line.strip().startswith("#")
|
|
11
|
+
)
|
|
12
|
+
ffibuilder.cdef(filtered_header)
|
|
13
|
+
|
|
14
|
+
ffibuilder.set_source(
|
|
15
|
+
"pytest_codspeed.instruments.hooks.dist_instrument_hooks",
|
|
16
|
+
"""
|
|
17
|
+
#include "core.h"
|
|
18
|
+
""",
|
|
19
|
+
sources=[
|
|
20
|
+
"src/pytest_codspeed/instruments/hooks/instrument-hooks/dist/core.c",
|
|
21
|
+
],
|
|
22
|
+
include_dirs=[str(includes_dir)],
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
if __name__ == "__main__":
|
|
26
|
+
ffibuilder.compile(verbose=True)
|