1
1
import json
2
2
import pathlib
3
3
from statistics import mean
4
- from typing import Any # noqa: F401
4
+ from typing import Any
5
5
6
6
from graph .common import fatal
7
7
from hwbench .bench .monitoring_structs import (
19
19
MEAN = "mean"
20
20
21
21
22
+ METRIC_AXIs = {
23
+ "Percent" : (100 , 10 , 5 ),
24
+ "RPM" : (21000 , 1000 , 250 ),
25
+ "Celsius" : (110 , 10 , 5 ),
26
+ }
27
+
28
+
22
29
class Bench :
23
30
def __init__ (self , trace , bench_name : str ):
24
31
self .trace = trace
@@ -68,12 +75,12 @@ def load_monitoring(self):
68
75
self .metrics = {}
69
76
m = self .get_monitoring ()
70
77
if m :
71
- for metric in m . keys () :
78
+ for metric in m :
72
79
if metric in MonitoringMetadata .list_str ():
73
80
self .metrics [metric ] = m [metric ]
74
81
elif metric in Metrics .list_str ():
75
82
self .metrics [metric ] = {}
76
- for component_family in m [metric ]. keys () :
83
+ for component_family in m [metric ]:
77
84
self .metrics [metric ][component_family ] = {}
78
85
for measure in m [metric ][component_family ]:
79
86
original_measure = m [metric ][component_family ][measure ]
@@ -100,14 +107,7 @@ def get_monitoring_metric_by_name(self, metric: Metrics, metric_name: str) -> Mo
100
107
101
108
def get_monitoring_metric_axis (self , unit : str ) -> tuple [Any , Any , Any ]:
102
109
"""Return adjusted metric axis values"""
103
- # return y_max, y_major_tick, y_minor_tick
104
- if unit == "Percent" :
105
- return 100 , 10 , 5
106
- elif unit == "RPM" :
107
- return 21000 , 1000 , 250
108
- elif unit == "Celsius" :
109
- return 110 , 10 , 5
110
- return None , None , None
110
+ return METRIC_AXIs .get (unit , (None , None , None ))
111
111
112
112
def get_component (self , metric_type : Metrics , component : Any ) -> dict [str , MonitorMetric ]:
113
113
return self .get_monitoring_metric (metric_type )[str (component )]
@@ -153,8 +153,8 @@ def get_system_title(self):
153
153
d = self .get_trace ().get_dmi ()
154
154
c = self .get_trace ().get_cpu ()
155
155
k = self .get_trace ().get_kernel ()
156
- title = f"System: { d ['serial' ]} { d ['product' ]} Bios " f" v{ d ['bios' ]['version' ]} Linux Kernel { k ['release' ]} "
157
- title += f"\n Processor: { c ['model' ]} with { c ['physical_cores' ]} cores " f" and { c ['numa_domains' ]} NUMA domains"
156
+ title = f"System: { d ['serial' ]} { d ['product' ]} Bios v{ d ['bios' ]['version' ]} Linux Kernel { k ['release' ]} "
157
+ title += f"\n Processor: { c ['model' ]} with { c ['physical_cores' ]} cores and { c ['numa_domains' ]} NUMA domains"
158
158
return title
159
159
160
160
def job_name (self ) -> str :
@@ -449,10 +449,11 @@ def validate(self) -> None:
449
449
def _list_power_metrics (self ) -> list [str ]:
450
450
first_bench = self .first_bench ()
451
451
first_bench .load_monitoring ()
452
- power_metrics = []
453
- for name , value in first_bench .get_monitoring_metric (Metrics .POWER_CONSUMPTION ).items ():
454
- for v in value :
455
- power_metrics .append (f"{ name } .{ v } " )
452
+ power_metrics = [
453
+ f"{ name } .{ v } "
454
+ for name , value in first_bench .get_monitoring_metric (Metrics .POWER_CONSUMPTION ).items ()
455
+ for v in value
456
+ ]
456
457
return power_metrics
457
458
458
459
def list_power_metrics (self ):
0 commit comments