summaryrefslogtreecommitdiff
path: root/tools/perf
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2025-12-02 09:50:07 -0800
committerNamhyung Kim <namhyung@kernel.org>2025-12-02 16:12:50 -0800
commitd9f2ce394c91c28728481564168a59aa5bac376f (patch)
tree9627499100c8c5fe6612fd4322ffe9771fafccb8 /tools/perf
parenta1d9bb1a047286b36a06a5353a266e8baac4b93d (diff)
perf jevents: Skip optional metrics in metric group list
For metric groups, skip metrics in the list that are None. This allows functions to better optionally return metrics. Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Thomas Falcon <thomas.falcon@intel.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/pmu-events/metric.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py
index b39189182608..dd8fd06940e6 100644
--- a/tools/perf/pmu-events/metric.py
+++ b/tools/perf/pmu-events/metric.py
@@ -493,13 +493,15 @@ class MetricGroup:
"""
def __init__(self, name: str,
- metric_list: List[Union[Metric, 'MetricGroup']],
+ metric_list: List[Union[Optional[Metric], Optional['MetricGroup']]],
description: Optional[str] = None):
self.name = name
- self.metric_list = metric_list
+ self.metric_list = []
self.description = description
for metric in metric_list:
- metric.AddToMetricGroup(self)
+ if metric:
+ self.metric_list.append(metric)
+ metric.AddToMetricGroup(self)
def AddToMetricGroup(self, group):
"""Callback used when a MetricGroup is added into another."""