Skip to content

Commit e864c5c

Browse files
Andi Kleenacmel
authored andcommitted
perf stat: Hide internal duration_time counter
Some perf stat metrics use an internal "duration_time" metric. It is not correctly printed however. So hide it during output to avoid confusing users with 0 counts. Signed-off-by: Andi Kleen <[email protected]> Acked-by: Jiri Olsa <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent fd48aad commit e864c5c

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

tools/perf/builtin-stat.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ static struct perf_stat_config stat_config = {
195195
.scale = true,
196196
};
197197

198+
static bool is_duration_time(struct perf_evsel *evsel)
199+
{
200+
return !strcmp(evsel->name, "duration_time");
201+
}
202+
198203
static inline void diff_timespec(struct timespec *r, struct timespec *a,
199204
struct timespec *b)
200205
{
@@ -1363,6 +1368,9 @@ static void print_aggr(char *prefix)
13631368
ad.id = id = aggr_map->map[s];
13641369
first = true;
13651370
evlist__for_each_entry(evsel_list, counter) {
1371+
if (is_duration_time(counter))
1372+
continue;
1373+
13661374
ad.val = ad.ena = ad.run = 0;
13671375
ad.nr = 0;
13681376
if (!collect_data(counter, aggr_cb, &ad))
@@ -1506,6 +1514,8 @@ static void print_no_aggr_metric(char *prefix)
15061514
if (prefix)
15071515
fputs(prefix, stat_config.output);
15081516
evlist__for_each_entry(evsel_list, counter) {
1517+
if (is_duration_time(counter))
1518+
continue;
15091519
if (first) {
15101520
aggr_printout(counter, cpu, 0);
15111521
first = false;
@@ -1560,6 +1570,8 @@ static void print_metric_headers(const char *prefix, bool no_indent)
15601570

15611571
/* Print metrics headers only */
15621572
evlist__for_each_entry(evsel_list, counter) {
1573+
if (is_duration_time(counter))
1574+
continue;
15631575
os.evsel = counter;
15641576
out.ctx = &os;
15651577
out.print_metric = print_metric_header;
@@ -1707,21 +1719,30 @@ static void print_counters(struct timespec *ts, int argc, const char **argv)
17071719
print_aggr(prefix);
17081720
break;
17091721
case AGGR_THREAD:
1710-
evlist__for_each_entry(evsel_list, counter)
1722+
evlist__for_each_entry(evsel_list, counter) {
1723+
if (is_duration_time(counter))
1724+
continue;
17111725
print_aggr_thread(counter, prefix);
1726+
}
17121727
break;
17131728
case AGGR_GLOBAL:
1714-
evlist__for_each_entry(evsel_list, counter)
1729+
evlist__for_each_entry(evsel_list, counter) {
1730+
if (is_duration_time(counter))
1731+
continue;
17151732
print_counter_aggr(counter, prefix);
1733+
}
17161734
if (metric_only)
17171735
fputc('\n', stat_config.output);
17181736
break;
17191737
case AGGR_NONE:
17201738
if (metric_only)
17211739
print_no_aggr_metric(prefix);
17221740
else {
1723-
evlist__for_each_entry(evsel_list, counter)
1741+
evlist__for_each_entry(evsel_list, counter) {
1742+
if (is_duration_time(counter))
1743+
continue;
17241744
print_counter(counter, prefix);
1745+
}
17251746
}
17261747
break;
17271748
case AGGR_UNSET:

0 commit comments

Comments
 (0)