Skip to content

Commit 0c5268b

Browse files
Jiri Olsaacmel
authored andcommitted
perf hists browser: Add support to display whole group data for raw columns
Currently we don't display group members' values for raw columns like 'Samples' and 'Period' when in group report mode. Uniting '__hpp__percent_fmt' and '__hpp__raw_fmt' function under new function __hpp__fmt. It's basically '__hpp__percent_fmt' code with new 'fmt_percent' bool parameter added saying whether raw number or percentage should be printed. This way raw columns print out all the group members when in group report mode, like: $ perf record -e '{cycles,cache-misses}' ls ... $ perf report --group --show-total-period --stdio ... # Overhead Period Command Shared Object Symbol # ................ ........................ ....... ................. ................................. # 23.63% 11.24% 3331335 317 ls [kernel.kallsyms] [k] __lock_acquire 12.72% 0.00% 1793100 0 ls [kernel.kallsyms] [k] native_sched_clock 9.72% 0.00% 1369920 0 ls libc-2.14.90.so [.] _nl_find_locale 0.03% 0.07% 4476 2 ls [kernel.kallsyms] [k] intel_pmu_enable_all 0.00% 11.73% 0 331 ls ld-2.14.90.so [.] _dl_cache_libcmp 0.00% 11.06% 0 312 ls [kernel.kallsyms] [k] vma_interval_tree_insert Signed-off-by: Jiri Olsa <jolsa@redhat.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1359981185-16819-2-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent d7e7a45 commit 0c5268b

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

‎tools/perf/ui/hist.c‎

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@
99

1010
typedef int (*hpp_snprint_fn)(char *buf, size_t size, const char *fmt, ...);
1111

12-
static int __hpp__percent_fmt(struct perf_hpp *hpp, struct hist_entry *he,
13-
u64 (*get_field)(struct hist_entry *),
14-
const char *fmt, hpp_snprint_fn print_fn)
12+
static int __hpp__fmt(struct perf_hpp *hpp, struct hist_entry *he,
13+
u64 (*get_field)(struct hist_entry *),
14+
const char *fmt, hpp_snprint_fn print_fn,
15+
bool fmt_percent)
1516
{
1617
int ret;
17-
double percent = 0.0;
1818
struct hists *hists = he->hists;
1919

20-
if (hists->stats.total_period)
21-
percent = 100.0 * get_field(he) / hists->stats.total_period;
20+
if (fmt_percent) {
21+
double percent = 0.0;
22+
23+
if (hists->stats.total_period)
24+
percent = 100.0 * get_field(he) /
25+
hists->stats.total_period;
2226

23-
ret = print_fn(hpp->buf, hpp->size, fmt, percent);
27+
ret = print_fn(hpp->buf, hpp->size, fmt, percent);
28+
} else
29+
ret = print_fn(hpp->buf, hpp->size, fmt, get_field(he));
2430

2531
if (symbol_conf.event_group) {
2632
int prev_idx, idx_delta;
@@ -49,11 +55,15 @@ static int __hpp__percent_fmt(struct perf_hpp *hpp, struct hist_entry *he,
4955
* have no sample
5056
*/
5157
ret += print_fn(hpp->buf + ret, hpp->size - ret,
52-
fmt, 0.0);
58+
fmt, 0);
5359
}
5460

55-
ret += print_fn(hpp->buf + ret, hpp->size - ret,
56-
fmt, 100.0 * period / total);
61+
if (fmt_percent)
62+
ret += print_fn(hpp->buf + ret, hpp->size - ret,
63+
fmt, 100.0 * period / total);
64+
else
65+
ret += print_fn(hpp->buf + ret, hpp->size - ret,
66+
fmt, period);
5767

5868
prev_idx = perf_evsel__group_idx(evsel);
5969
}
@@ -65,23 +75,12 @@ static int __hpp__percent_fmt(struct perf_hpp *hpp, struct hist_entry *he,
6575
* zero-fill group members at last which have no sample
6676
*/
6777
ret += print_fn(hpp->buf + ret, hpp->size - ret,
68-
fmt, 0.0);
78+
fmt, 0);
6979
}
7080
}
7181
return ret;
7282
}
7383

74-
static int __hpp__raw_fmt(struct perf_hpp *hpp, struct hist_entry *he,
75-
u64 (*get_field)(struct hist_entry *),
76-
const char *fmt, hpp_snprint_fn print_fn)
77-
{
78-
int ret;
79-
80-
ret = print_fn(hpp->buf, hpp->size, fmt, get_field(he));
81-
return ret;
82-
}
83-
84-
8584
#define __HPP_HEADER_FN(_type, _str, _min_width, _unit_width) \
8685
static int hpp__header_##_type(struct perf_hpp *hpp) \
8786
{ \
@@ -116,16 +115,16 @@ static u64 he_get_##_field(struct hist_entry *he) \
116115
\
117116
static int hpp__color_##_type(struct perf_hpp *hpp, struct hist_entry *he) \
118117
{ \
119-
return __hpp__percent_fmt(hpp, he, he_get_##_field, " %6.2f%%", \
120-
(hpp_snprint_fn)percent_color_snprintf); \
118+
return __hpp__fmt(hpp, he, he_get_##_field, " %6.2f%%", \
119+
(hpp_snprint_fn)percent_color_snprintf, true); \
121120
}
122121

123122
#define __HPP_ENTRY_PERCENT_FN(_type, _field) \
124123
static int hpp__entry_##_type(struct perf_hpp *hpp, struct hist_entry *he) \
125124
{ \
126125
const char *fmt = symbol_conf.field_sep ? " %.2f" : " %6.2f%%"; \
127-
return __hpp__percent_fmt(hpp, he, he_get_##_field, fmt, \
128-
scnprintf); \
126+
return __hpp__fmt(hpp, he, he_get_##_field, fmt, \
127+
scnprintf, true); \
129128
}
130129

131130
#define __HPP_ENTRY_RAW_FN(_type, _field) \
@@ -137,7 +136,7 @@ static u64 he_get_raw_##_field(struct hist_entry *he) \
137136
static int hpp__entry_##_type(struct perf_hpp *hpp, struct hist_entry *he) \
138137
{ \
139138
const char *fmt = symbol_conf.field_sep ? " %"PRIu64 : " %11"PRIu64; \
140-
return __hpp__raw_fmt(hpp, he, he_get_raw_##_field, fmt, scnprintf); \
139+
return __hpp__fmt(hpp, he, he_get_raw_##_field, fmt, scnprintf, false); \
141140
}
142141

143142
#define HPP_PERCENT_FNS(_type, _str, _field, _min_width, _unit_width) \

0 commit comments

Comments
 (0)