Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf jevents: Add descriptions to metricgroup abstraction

Add a function to recursively generate metric group descriptions.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
38d9d511 e7b9e750

+12 -2
+12 -2
tools/perf/pmu-events/metric.py
··· 475 475 476 476 return result 477 477 478 + def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]: 479 + return {} 478 480 479 481 class _MetricJsonEncoder(json.JSONEncoder): 480 482 """Special handling for Metric objects.""" ··· 495 493 which can facilitate arrangements similar to trees. 496 494 """ 497 495 498 - def __init__(self, name: str, metric_list: List[Union[Metric, 499 - 'MetricGroup']]): 496 + def __init__(self, name: str, 497 + metric_list: List[Union[Metric, 'MetricGroup']], 498 + description: Optional[str] = None): 500 499 self.name = name 501 500 self.metric_list = metric_list 501 + self.description = description 502 502 for metric in metric_list: 503 503 metric.AddToMetricGroup(self) 504 504 ··· 519 515 520 516 def ToPerfJson(self) -> str: 521 517 return json.dumps(sorted(self.Flatten()), indent=2, cls=_MetricJsonEncoder) 518 + 519 + def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]: 520 + result = {self.name: self.description} if self.description else {} 521 + for x in self.metric_list: 522 + result.update(x.ToMetricGroupDescriptions(False)) 523 + return result 522 524 523 525 def __str__(self) -> str: 524 526 return self.ToPerfJson()