Skip to content

Commit

Permalink
perf list: For metricgroup only list include description
Browse files Browse the repository at this point in the history
If perf list is invoked with 'metricgroups' include the description
unless it is invoked with flags to exclude it. Make the description of
metricgroup dumping dependent on the desc flag in print_state as with
metrics.

Before:
```
$ perf list metricgroups
List of pre-defined events (to be used in -e or -M):

Metric Groups:

Backend
Bad
BadSpec
...
```

After:
```
$ perf list metricgroups
List of pre-defined events (to be used in -e or -M):

Metric Groups:

Backend [Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet]
Bad [Grouping from Top-down Microarchitecture Analysis Metrics spreadsheet]
BadSpec
...
```

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240216192044.119897-1-irogers@google.com
  • Loading branch information
captain5050 authored and namhyung committed Feb 17, 2024
1 parent bacefe0 commit 81377de
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions tools/perf/builtin-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,24 @@ static void default_print_metric(void *ps,
if (!print_state->last_metricgroups ||
strcmp(print_state->last_metricgroups, group ?: "")) {
if (group && print_state->metricgroups) {
if (print_state->name_only)
if (print_state->name_only) {
fprintf(fp, "%s ", group);
else if (print_state->metrics) {
const char *gdesc = describe_metricgroup(group);
} else {
const char *gdesc = print_state->desc
? describe_metricgroup(group)
: NULL;
const char *print_colon = "";

if (print_state->metrics) {
print_colon = ":";
fputc('\n', fp);
}

if (gdesc)
fprintf(fp, "\n%s: [%s]\n", group, gdesc);
fprintf(fp, "%s%s [%s]\n", group, print_colon, gdesc);
else
fprintf(fp, "\n%s:\n", group);
} else
fprintf(fp, "%s\n", group);
fprintf(fp, "%s%s\n", group, print_colon);
}
}
zfree(&print_state->last_metricgroups);
print_state->last_metricgroups = strdup(group ?: "");
Expand Down

0 comments on commit 81377de

Please sign in to comment.