[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240314055051.1960527-4-irogers@google.com>
Date: Wed, 13 Mar 2024 22:50:42 -0700
From: Ian Rogers <irogers@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
John Garry <john.g.garry@...cle.com>, Kan Liang <kan.liang@...ux.intel.com>,
Jing Zhang <renyu.zj@...ux.alibaba.com>, Thomas Richter <tmricht@...ux.ibm.com>,
James Clark <james.clark@....com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, Andi Kleen <ak@...ux.intel.com>,
Kajol Jain <kjain@...ux.ibm.com>, Sandipan Das <sandipan.das@....com>,
Ravi Bangoria <ravi.bangoria@....com>, Perry Taylor <perry.taylor@...el.com>,
Samantha Alt <samantha.alt@...el.com>, Caleb Biggers <caleb.biggers@...el.com>,
Weilin Wang <weilin.wang@...el.com>, Edward Baker <edward.baker@...el.com>,
Stephane Eranian <eranian@...gle.com>
Subject: [PATCH v3 03/12] perf jevents: Add descriptions to metricgroup abstraction
Add a function to recursively generate metric group descriptions.
Signed-off-by: Ian Rogers <irogers@...gle.com>
---
tools/perf/pmu-events/metric.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py
index 8a718dd4b1fe..1de4fb72c75e 100644
--- a/tools/perf/pmu-events/metric.py
+++ b/tools/perf/pmu-events/metric.py
@@ -475,6 +475,8 @@ class Metric:
return result
+ def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]:
+ return {}
class _MetricJsonEncoder(json.JSONEncoder):
"""Special handling for Metric objects."""
@@ -493,10 +495,12 @@ class MetricGroup:
which can facilitate arrangements similar to trees.
"""
- def __init__(self, name: str, metric_list: List[Union[Metric,
- 'MetricGroup']]):
+ def __init__(self, name: str,
+ metric_list: List[Union[Metric, 'MetricGroup']],
+ description: Optional[str] = None):
self.name = name
self.metric_list = metric_list
+ self.description = description
for metric in metric_list:
metric.AddToMetricGroup(self)
@@ -516,6 +520,12 @@ class MetricGroup:
def ToPerfJson(self) -> str:
return json.dumps(sorted(self.Flatten()), indent=2, cls=_MetricJsonEncoder)
+ def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]:
+ result = {self.name: self.description} if self.description else {}
+ for x in self.metric_list:
+ result.update(x.ToMetricGroupDescriptions(False))
+ return result
+
def __str__(self) -> str:
return self.ToPerfJson()
--
2.44.0.278.ge034bb2e1d-goog
Powered by blists - more mailing lists