File tree Expand file tree Collapse file tree
src/pytest_codspeed/instruments Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[submodule "tests/benchmarks/TheAlgorithms "]
22 path = tests/benchmarks/TheAlgorithms
33 url = git@github.com:TheAlgorithms/Python.git
4+ [submodule "src/pytest_codspeed/instruments/hooks "]
5+ path = src/pytest_codspeed/instruments/hooks
6+ url = https://github.com/CodSpeedHQ/instrument-hooks
Original file line number Diff line number Diff line change 66from setuptools import setup
77
88build_path = (
9- Path (__file__ ).parent / "src/pytest_codspeed/instruments/valgrind/_wrapper /build.py"
9+ Path (__file__ ).parent / "src/pytest_codspeed/instruments/hooks /build.py"
1010)
1111
1212spec = importlib .util .spec_from_file_location ("build" , build_path )
Original file line number Diff line number Diff line change 1+ import os
2+ from typing import Optional
3+
4+ from pytest_codspeed .core import lib
5+
6+ class InstrumentHooks :
7+ """Core library wrapper class providing benchmark measurement functionality."""
8+
9+ @staticmethod
10+ def start_benchmark () -> None :
11+ """Start a new benchmark measurement."""
12+ lib .start_benchmark ()
13+
14+ @staticmethod
15+ def stop_benchmark () -> None :
16+ """Stop the current benchmark measurement."""
17+ lib .stop_benchmark ()
18+
19+ @staticmethod
20+ def set_current_benchmark (uri : str , pid : Optional [int ] = None ) -> None :
21+ """Set the current benchmark URI and process ID.
22+
23+ Args:
24+ uri: The benchmark URI string identifier
25+ pid: Optional process ID (defaults to current process)
26+ """
27+ if pid is None :
28+ pid = os .getpid ()
29+ lib .current_benchmark (pid , uri .encode ('ascii' ))
30+
31+ @staticmethod
32+ def set_integration (name : str , version : str ) -> None :
33+ """Set the integration name and version."""
34+ lib .set_integration (name .encode ('ascii' ), version .encode ('ascii' ))
35+
36+ @staticmethod
37+ def is_instrumented () -> bool :
38+ """Check if instrumentation is active."""
39+ return lib .is_instrumented ()
Original file line number Diff line number Diff line change 1+ from pathlib import Path
2+ from cffi import FFI # type: ignore
3+
4+ ffibuilder = FFI ()
5+
6+ dist_dir = Path (__file__ ).parent .joinpath ("instrument-hooks/dist" )
7+ header_text = (dist_dir / "core.h" ).read_text ()
8+ filtered_header = "\n " .join (
9+ line for line in header_text .splitlines ()
10+ if not line .strip ().startswith ("#" )
11+ )
12+ ffibuilder .cdef (filtered_header )
13+
14+ ffibuilder .set_source (
15+ "pytest_codspeed.core" ,
16+ "" ,
17+ libraries = ["m" , "quadmath" ],
18+ sources = [
19+ "src/pytest_codspeed/instruments/core/instrument-hooks/dist/core.c" ,
20+ "src/pytest_codspeed/instruments/core/instrument-hooks/dist/wrapper.c" ,
21+ ],
22+ include_dirs = [str (dist_dir )],
23+ extra_compile_args = ["-lm" , "-lcs50" ],
24+ )
25+
26+ if __name__ == "__main__" :
27+ ffibuilder .compile (verbose = True )
Original file line number Diff line number Diff line change 1+ Subproject commit 3363c83d15532a981c4a4c9985871ceebb546ed4
File renamed without changes.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments