14
14
15
15
from pytest import Session
16
16
17
- from pytest_codspeed .benchmark import Benchmark
17
+ from pytest_codspeed .benchmark import BenchmarkMetadata
18
18
from pytest_codspeed .instruments import P , T
19
19
from pytest_codspeed .instruments .valgrind ._wrapper import LibType
20
20
from pytest_codspeed .plugin import CodSpeedConfig
@@ -28,7 +28,7 @@ class ValgrindInstrument(Instrument):
28
28
29
29
def __init__ (self , config : CodSpeedConfig ) -> None :
30
30
self .benchmark_count = 0
31
- self .benchmarks : list [Benchmark ] = []
31
+ self .benchmarks_metadata : list [BenchmarkMetadata ] = []
32
32
self .should_measure = os .environ .get ("CODSPEED_ENV" ) is not None
33
33
if self .should_measure :
34
34
self .lib = get_lib ()
@@ -57,13 +57,13 @@ def get_instrument_config_str_and_warns(self) -> tuple[str, list[str]]:
57
57
58
58
def measure (
59
59
self ,
60
- benchmark : Benchmark ,
60
+ benchmark_metadata : BenchmarkMetadata ,
61
61
fn : Callable [P , T ],
62
62
* args : P .args ,
63
63
** kwargs : P .kwargs ,
64
64
) -> T :
65
65
self .benchmark_count += 1
66
- self .benchmarks .append (benchmark )
66
+ self .benchmarks_metadata .append (benchmark_metadata )
67
67
if self .lib is None : # Thus should_measure is False
68
68
return fn (* args , ** kwargs )
69
69
@@ -81,7 +81,7 @@ def __codspeed_root_frame__() -> T:
81
81
finally :
82
82
# Ensure instrumentation is stopped even if the test failed
83
83
self .lib .stop_instrumentation ()
84
- self .lib .dump_stats_at (benchmark .to_json_string ().encode ("ascii" ))
84
+ self .lib .dump_stats_at (benchmark_metadata .to_json_string ().encode ("ascii" ))
85
85
86
86
def report (self , session : Session ) -> None :
87
87
reporter = session .config .pluginmanager .get_plugin ("terminalreporter" )
@@ -94,5 +94,5 @@ def report(self, session: Session) -> None:
94
94
def get_result_dict (self ) -> dict [str , Any ]:
95
95
return {
96
96
"instrument" : {"type" : self .instrument },
97
- "benchmarks" : [asdict (bench ) for bench in self .benchmarks ],
97
+ "benchmarks" : [asdict (bench ) for bench in self .benchmarks_metadata ],
98
98
}
0 commit comments