diff options
Diffstat (limited to 'tools/perf/ui/hist.c')
-rw-r--r-- | tools/perf/ui/hist.c | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 849c40028e7b..a47ce98c2cb1 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -21,6 +21,53 @@ static int __hpp__percent_fmt(struct perf_hpp *hpp, struct hist_entry *he, | |||
21 | percent = 100.0 * get_field(he) / hists->stats.total_period; | 21 | percent = 100.0 * get_field(he) / hists->stats.total_period; |
22 | 22 | ||
23 | ret = print_fn(hpp->buf, hpp->size, fmt, percent); | 23 | ret = print_fn(hpp->buf, hpp->size, fmt, percent); |
24 | |||
25 | if (symbol_conf.event_group) { | ||
26 | int prev_idx, idx_delta; | ||
27 | struct perf_evsel *evsel = hists_to_evsel(hists); | ||
28 | struct hist_entry *pair; | ||
29 | int nr_members = evsel->nr_members; | ||
30 | |||
31 | if (nr_members <= 1) | ||
32 | return ret; | ||
33 | |||
34 | prev_idx = perf_evsel__group_idx(evsel); | ||
35 | |||
36 | list_for_each_entry(pair, &he->pairs.head, pairs.node) { | ||
37 | u64 period = get_field(pair); | ||
38 | u64 total = pair->hists->stats.total_period; | ||
39 | |||
40 | if (!total) | ||
41 | continue; | ||
42 | |||
43 | evsel = hists_to_evsel(pair->hists); | ||
44 | idx_delta = perf_evsel__group_idx(evsel) - prev_idx - 1; | ||
45 | |||
46 | while (idx_delta--) { | ||
47 | /* | ||
48 | * zero-fill group members in the middle which | ||
49 | * have no sample | ||
50 | */ | ||
51 | ret += print_fn(hpp->buf + ret, hpp->size - ret, | ||
52 | fmt, 0.0); | ||
53 | } | ||
54 | |||
55 | ret += print_fn(hpp->buf + ret, hpp->size - ret, | ||
56 | fmt, 100.0 * period / total); | ||
57 | |||
58 | prev_idx = perf_evsel__group_idx(evsel); | ||
59 | } | ||
60 | |||
61 | idx_delta = nr_members - prev_idx - 1; | ||
62 | |||
63 | while (idx_delta--) { | ||
64 | /* | ||
65 | * zero-fill group members at last which have no sample | ||
66 | */ | ||
67 | ret += print_fn(hpp->buf + ret, hpp->size - ret, | ||
68 | fmt, 0.0); | ||
69 | } | ||
70 | } | ||
24 | return ret; | 71 | return ret; |
25 | } | 72 | } |
26 | 73 | ||
@@ -40,6 +87,11 @@ static int hpp__header_##_type(struct perf_hpp *hpp) \ | |||
40 | { \ | 87 | { \ |
41 | int len = _min_width; \ | 88 | int len = _min_width; \ |
42 | \ | 89 | \ |
90 | if (symbol_conf.event_group) { \ | ||
91 | struct perf_evsel *evsel = hpp->ptr; \ | ||
92 | \ | ||
93 | len = max(len, evsel->nr_members * _unit_width); \ | ||
94 | } \ | ||
43 | return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \ | 95 | return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \ |
44 | } | 96 | } |
45 | 97 | ||
@@ -48,6 +100,11 @@ static int hpp__width_##_type(struct perf_hpp *hpp __maybe_unused) \ | |||
48 | { \ | 100 | { \ |
49 | int len = _min_width; \ | 101 | int len = _min_width; \ |
50 | \ | 102 | \ |
103 | if (symbol_conf.event_group) { \ | ||
104 | struct perf_evsel *evsel = hpp->ptr; \ | ||
105 | \ | ||
106 | len = max(len, evsel->nr_members * _unit_width); \ | ||
107 | } \ | ||
51 | return len; \ | 108 | return len; \ |
52 | } | 109 | } |
53 | 110 | ||
@@ -438,12 +495,15 @@ unsigned int hists__sort_list_width(struct hists *hists) | |||
438 | struct perf_hpp_fmt *fmt; | 495 | struct perf_hpp_fmt *fmt; |
439 | struct sort_entry *se; | 496 | struct sort_entry *se; |
440 | int i = 0, ret = 0; | 497 | int i = 0, ret = 0; |
498 | struct perf_hpp dummy_hpp = { | ||
499 | .ptr = hists_to_evsel(hists), | ||
500 | }; | ||
441 | 501 | ||
442 | perf_hpp__for_each_format(fmt) { | 502 | perf_hpp__for_each_format(fmt) { |
443 | if (i) | 503 | if (i) |
444 | ret += 2; | 504 | ret += 2; |
445 | 505 | ||
446 | ret += fmt->width(NULL); | 506 | ret += fmt->width(&dummy_hpp); |
447 | } | 507 | } |
448 | 508 | ||
449 | list_for_each_entry(se, &hist_entry__sort_list, list) | 509 | list_for_each_entry(se, &hist_entry__sort_list, list) |