Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350020
b: refs/heads/master
c: 5b9e214
h: refs/heads/master
v: v3
  • Loading branch information
Namhyung Kim authored and Arnaldo Carvalho de Melo committed Jan 31, 2013
1 parent a9f59e6 commit 124e08a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 843985e953ddcc3d57a62641b377c8d3222859e2
refs/heads/master: 5b9e2146ec4f8c6d436f9f7043a0409a4296a705
62 changes: 61 additions & 1 deletion trunk/tools/perf/ui/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,53 @@ static int __hpp__percent_fmt(struct perf_hpp *hpp, struct hist_entry *he,
percent = 100.0 * get_field(he) / hists->stats.total_period;

ret = print_fn(hpp->buf, hpp->size, fmt, percent);

if (symbol_conf.event_group) {
int prev_idx, idx_delta;
struct perf_evsel *evsel = hists_to_evsel(hists);
struct hist_entry *pair;
int nr_members = evsel->nr_members;

if (nr_members <= 1)
return ret;

prev_idx = perf_evsel__group_idx(evsel);

list_for_each_entry(pair, &he->pairs.head, pairs.node) {
u64 period = get_field(pair);
u64 total = pair->hists->stats.total_period;

if (!total)
continue;

evsel = hists_to_evsel(pair->hists);
idx_delta = perf_evsel__group_idx(evsel) - prev_idx - 1;

while (idx_delta--) {
/*
* zero-fill group members in the middle which
* have no sample
*/
ret += print_fn(hpp->buf + ret, hpp->size - ret,
fmt, 0.0);
}

ret += print_fn(hpp->buf + ret, hpp->size - ret,
fmt, 100.0 * period / total);

prev_idx = perf_evsel__group_idx(evsel);
}

idx_delta = nr_members - prev_idx - 1;

while (idx_delta--) {
/*
* zero-fill group members at last which have no sample
*/
ret += print_fn(hpp->buf + ret, hpp->size - ret,
fmt, 0.0);
}
}
return ret;
}

Expand All @@ -40,6 +87,11 @@ static int hpp__header_##_type(struct perf_hpp *hpp) \
{ \
int len = _min_width; \
\
if (symbol_conf.event_group) { \
struct perf_evsel *evsel = hpp->ptr; \
\
len = max(len, evsel->nr_members * _unit_width); \
} \
return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \
}

Expand All @@ -48,6 +100,11 @@ static int hpp__width_##_type(struct perf_hpp *hpp __maybe_unused) \
{ \
int len = _min_width; \
\
if (symbol_conf.event_group) { \
struct perf_evsel *evsel = hpp->ptr; \
\
len = max(len, evsel->nr_members * _unit_width); \
} \
return len; \
}

Expand Down Expand Up @@ -438,12 +495,15 @@ unsigned int hists__sort_list_width(struct hists *hists)
struct perf_hpp_fmt *fmt;
struct sort_entry *se;
int i = 0, ret = 0;
struct perf_hpp dummy_hpp = {
.ptr = hists_to_evsel(hists),
};

perf_hpp__for_each_format(fmt) {
if (i)
ret += 2;

ret += fmt->width(NULL);
ret += fmt->width(&dummy_hpp);
}

list_for_each_entry(se, &hist_entry__sort_list, list)
Expand Down
2 changes: 2 additions & 0 deletions trunk/tools/perf/ui/stdio/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../../util/util.h"
#include "../../util/hist.h"
#include "../../util/sort.h"
#include "../../util/evsel.h"


static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
Expand Down Expand Up @@ -347,6 +348,7 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows,
struct perf_hpp dummy_hpp = {
.buf = bf,
.size = sizeof(bf),
.ptr = hists_to_evsel(hists),
};
bool first = true;

Expand Down

0 comments on commit 124e08a

Please sign in to comment.