12
12
from .table import ResultsTable
13
13
from .utils import SecondsDecimal
14
14
from .utils import annotate_source
15
+ from .utils import cached_property
15
16
from .utils import first_or_value
16
17
from .utils import get_machine_id
17
18
from .utils import load_timer
@@ -33,11 +34,6 @@ def __init__(self, config):
33
34
self .performance_regressions = []
34
35
self .benchmarks = []
35
36
self .machine_id = get_machine_id ()
36
- self .machine_info = config .hook .pytest_benchmark_generate_machine_info (config = self .config )
37
- self .config .hook .pytest_benchmark_update_machine_info (
38
- config = self .config ,
39
- machine_info = self .machine_info
40
- )
41
37
42
38
self .options = dict (
43
39
min_time = SecondsDecimal (config .getoption ("benchmark_min_time" )),
@@ -92,6 +88,15 @@ def __init__(self, config):
92
88
default_machine_id = self .machine_id , logger = self .logger )
93
89
self .histogram = first_or_value (config .getoption ("benchmark_histogram" ), False )
94
90
91
+ @cached_property
92
+ def machine_info (self ):
93
+ obj = self .config .hook .pytest_benchmark_generate_machine_info (config = self .config )
94
+ self .config .hook .pytest_benchmark_update_machine_info (
95
+ config = self .config ,
96
+ machine_info = obj
97
+ )
98
+ return obj
99
+
95
100
def prepare_benchmarks (self ):
96
101
for bench in self .benchmarks :
97
102
if bench :
0 commit comments