diff options
author | Jiri Olsa <jolsa@redhat.com> | 2012-10-04 08:49:40 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-04 12:31:30 -0400 |
commit | b5ff71c3bab10a7a4b321b5de072ac5bd73ef9a4 (patch) | |
tree | 592b9041b8ad7257272f6e902bddcb747ce77410 | |
parent | 1d77822ea6245e89149872405a3844e0778a004a (diff) |
perf diff: Removing the total_period argument from output code
The total_period is available in struct hists data via the 'struct
hist_entry::hists' pointer. There's no need to carry it through the
output code path.
Removing 'struct perf_hpp::total_period' pointer, because it's no longer
needed.
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1349354994-17853-7-git-send-email-namhyung@kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/ui/browsers/hists.c | 4 | ||||
-rw-r--r-- | tools/perf/ui/gtk/browser.c | 4 | ||||
-rw-r--r-- | tools/perf/ui/hist.c | 37 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 15 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 1 |
5 files changed, 35 insertions, 26 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index bbd11c2f69db..d359795454d0 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -569,7 +569,8 @@ static int hist_browser__show_callchain(struct hist_browser *browser, | |||
569 | static int hist_browser__hpp_color_ ## _name(struct perf_hpp *hpp, \ | 569 | static int hist_browser__hpp_color_ ## _name(struct perf_hpp *hpp, \ |
570 | struct hist_entry *he) \ | 570 | struct hist_entry *he) \ |
571 | { \ | 571 | { \ |
572 | double percent = 100.0 * he->_field / hpp->total_period; \ | 572 | struct hists *hists = he->hists; \ |
573 | double percent = 100.0 * he->_field / hists->stats.total_period;\ | ||
573 | *(double *)hpp->ptr = percent; \ | 574 | *(double *)hpp->ptr = percent; \ |
574 | return scnprintf(hpp->buf, hpp->size, "%6.2f%%", percent); \ | 575 | return scnprintf(hpp->buf, hpp->size, "%6.2f%%", percent); \ |
575 | } | 576 | } |
@@ -624,7 +625,6 @@ static int hist_browser__show_entry(struct hist_browser *browser, | |||
624 | struct perf_hpp hpp = { | 625 | struct perf_hpp hpp = { |
625 | .buf = s, | 626 | .buf = s, |
626 | .size = sizeof(s), | 627 | .size = sizeof(s), |
627 | .total_period = browser->hists->stats.total_period, | ||
628 | }; | 628 | }; |
629 | 629 | ||
630 | ui_browser__gotorc(&browser->b, row, 0); | 630 | ui_browser__gotorc(&browser->b, row, 0); |
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c index 2bc08f6af714..3cbb1d622ed2 100644 --- a/tools/perf/ui/gtk/browser.c +++ b/tools/perf/ui/gtk/browser.c | |||
@@ -49,7 +49,8 @@ static const char *perf_gtk__get_percent_color(double percent) | |||
49 | static int perf_gtk__hpp_color_ ## _name(struct perf_hpp *hpp, \ | 49 | static int perf_gtk__hpp_color_ ## _name(struct perf_hpp *hpp, \ |
50 | struct hist_entry *he) \ | 50 | struct hist_entry *he) \ |
51 | { \ | 51 | { \ |
52 | double percent = 100.0 * he->_field / hpp->total_period; \ | 52 | struct hists *hists = he->hists; \ |
53 | double percent = 100.0 * he->_field / hists->stats.total_period; \ | ||
53 | const char *markup; \ | 54 | const char *markup; \ |
54 | int ret = 0; \ | 55 | int ret = 0; \ |
55 | \ | 56 | \ |
@@ -102,7 +103,6 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists) | |||
102 | struct perf_hpp hpp = { | 103 | struct perf_hpp hpp = { |
103 | .buf = s, | 104 | .buf = s, |
104 | .size = sizeof(s), | 105 | .size = sizeof(s), |
105 | .total_period = hists->stats.total_period, | ||
106 | }; | 106 | }; |
107 | 107 | ||
108 | nr_cols = 0; | 108 | nr_cols = 0; |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index e8853f7780a3..7f043394bef1 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -18,14 +18,16 @@ static int hpp__width_overhead(struct perf_hpp *hpp __maybe_unused) | |||
18 | 18 | ||
19 | static int hpp__color_overhead(struct perf_hpp *hpp, struct hist_entry *he) | 19 | static int hpp__color_overhead(struct perf_hpp *hpp, struct hist_entry *he) |
20 | { | 20 | { |
21 | double percent = 100.0 * he->period / hpp->total_period; | 21 | struct hists *hists = he->hists; |
22 | double percent = 100.0 * he->period / hists->stats.total_period; | ||
22 | 23 | ||
23 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent); | 24 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent); |
24 | } | 25 | } |
25 | 26 | ||
26 | static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he) | 27 | static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he) |
27 | { | 28 | { |
28 | double percent = 100.0 * he->period / hpp->total_period; | 29 | struct hists *hists = he->hists; |
30 | double percent = 100.0 * he->period / hists->stats.total_period; | ||
29 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%"; | 31 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%"; |
30 | 32 | ||
31 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 33 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
@@ -45,13 +47,16 @@ static int hpp__width_overhead_sys(struct perf_hpp *hpp __maybe_unused) | |||
45 | 47 | ||
46 | static int hpp__color_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he) | 48 | static int hpp__color_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he) |
47 | { | 49 | { |
48 | double percent = 100.0 * he->period_sys / hpp->total_period; | 50 | struct hists *hists = he->hists; |
51 | double percent = 100.0 * he->period_sys / hists->stats.total_period; | ||
52 | |||
49 | return percent_color_snprintf(hpp->buf, hpp->size, "%6.2f%%", percent); | 53 | return percent_color_snprintf(hpp->buf, hpp->size, "%6.2f%%", percent); |
50 | } | 54 | } |
51 | 55 | ||
52 | static int hpp__entry_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he) | 56 | static int hpp__entry_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he) |
53 | { | 57 | { |
54 | double percent = 100.0 * he->period_sys / hpp->total_period; | 58 | struct hists *hists = he->hists; |
59 | double percent = 100.0 * he->period_sys / hists->stats.total_period; | ||
55 | const char *fmt = symbol_conf.field_sep ? "%.2f" : "%6.2f%%"; | 60 | const char *fmt = symbol_conf.field_sep ? "%.2f" : "%6.2f%%"; |
56 | 61 | ||
57 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 62 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
@@ -71,13 +76,16 @@ static int hpp__width_overhead_us(struct perf_hpp *hpp __maybe_unused) | |||
71 | 76 | ||
72 | static int hpp__color_overhead_us(struct perf_hpp *hpp, struct hist_entry *he) | 77 | static int hpp__color_overhead_us(struct perf_hpp *hpp, struct hist_entry *he) |
73 | { | 78 | { |
74 | double percent = 100.0 * he->period_us / hpp->total_period; | 79 | struct hists *hists = he->hists; |
80 | double percent = 100.0 * he->period_us / hists->stats.total_period; | ||
81 | |||
75 | return percent_color_snprintf(hpp->buf, hpp->size, "%6.2f%%", percent); | 82 | return percent_color_snprintf(hpp->buf, hpp->size, "%6.2f%%", percent); |
76 | } | 83 | } |
77 | 84 | ||
78 | static int hpp__entry_overhead_us(struct perf_hpp *hpp, struct hist_entry *he) | 85 | static int hpp__entry_overhead_us(struct perf_hpp *hpp, struct hist_entry *he) |
79 | { | 86 | { |
80 | double percent = 100.0 * he->period_us / hpp->total_period; | 87 | struct hists *hists = he->hists; |
88 | double percent = 100.0 * he->period_us / hists->stats.total_period; | ||
81 | const char *fmt = symbol_conf.field_sep ? "%.2f" : "%6.2f%%"; | 89 | const char *fmt = symbol_conf.field_sep ? "%.2f" : "%6.2f%%"; |
82 | 90 | ||
83 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 91 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
@@ -96,14 +104,17 @@ static int hpp__width_overhead_guest_sys(struct perf_hpp *hpp __maybe_unused) | |||
96 | static int hpp__color_overhead_guest_sys(struct perf_hpp *hpp, | 104 | static int hpp__color_overhead_guest_sys(struct perf_hpp *hpp, |
97 | struct hist_entry *he) | 105 | struct hist_entry *he) |
98 | { | 106 | { |
99 | double percent = 100.0 * he->period_guest_sys / hpp->total_period; | 107 | struct hists *hists = he->hists; |
108 | double percent = 100.0 * he->period_guest_sys / hists->stats.total_period; | ||
109 | |||
100 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%% ", percent); | 110 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%% ", percent); |
101 | } | 111 | } |
102 | 112 | ||
103 | static int hpp__entry_overhead_guest_sys(struct perf_hpp *hpp, | 113 | static int hpp__entry_overhead_guest_sys(struct perf_hpp *hpp, |
104 | struct hist_entry *he) | 114 | struct hist_entry *he) |
105 | { | 115 | { |
106 | double percent = 100.0 * he->period_guest_sys / hpp->total_period; | 116 | struct hists *hists = he->hists; |
117 | double percent = 100.0 * he->period_guest_sys / hists->stats.total_period; | ||
107 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%% "; | 118 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%% "; |
108 | 119 | ||
109 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 120 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
@@ -122,14 +133,17 @@ static int hpp__width_overhead_guest_us(struct perf_hpp *hpp __maybe_unused) | |||
122 | static int hpp__color_overhead_guest_us(struct perf_hpp *hpp, | 133 | static int hpp__color_overhead_guest_us(struct perf_hpp *hpp, |
123 | struct hist_entry *he) | 134 | struct hist_entry *he) |
124 | { | 135 | { |
125 | double percent = 100.0 * he->period_guest_us / hpp->total_period; | 136 | struct hists *hists = he->hists; |
137 | double percent = 100.0 * he->period_guest_us / hists->stats.total_period; | ||
138 | |||
126 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%% ", percent); | 139 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%% ", percent); |
127 | } | 140 | } |
128 | 141 | ||
129 | static int hpp__entry_overhead_guest_us(struct perf_hpp *hpp, | 142 | static int hpp__entry_overhead_guest_us(struct perf_hpp *hpp, |
130 | struct hist_entry *he) | 143 | struct hist_entry *he) |
131 | { | 144 | { |
132 | double percent = 100.0 * he->period_guest_us / hpp->total_period; | 145 | struct hists *hists = he->hists; |
146 | double percent = 100.0 * he->period_guest_us / hists->stats.total_period; | ||
133 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%% "; | 147 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%% "; |
134 | 148 | ||
135 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 149 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
@@ -230,6 +244,7 @@ static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he) | |||
230 | { | 244 | { |
231 | struct hist_entry *pair = he->pair; | 245 | struct hist_entry *pair = he->pair; |
232 | struct hists *pair_hists = pair ? pair->hists : NULL; | 246 | struct hists *pair_hists = pair ? pair->hists : NULL; |
247 | struct hists *hists = he->hists; | ||
233 | u64 old_total, new_total; | 248 | u64 old_total, new_total; |
234 | double old_percent = 0, new_percent = 0; | 249 | double old_percent = 0, new_percent = 0; |
235 | double diff; | 250 | double diff; |
@@ -240,7 +255,7 @@ static int hpp__entry_delta(struct perf_hpp *hpp, struct hist_entry *he) | |||
240 | if (old_total > 0 && pair) | 255 | if (old_total > 0 && pair) |
241 | old_percent = 100.0 * pair->period / old_total; | 256 | old_percent = 100.0 * pair->period / old_total; |
242 | 257 | ||
243 | new_total = hpp->total_period; | 258 | new_total = hists->stats.total_period; |
244 | if (new_total > 0) | 259 | if (new_total > 0) |
245 | new_percent = 100.0 * he->period / new_total; | 260 | new_percent = 100.0 * he->period / new_total; |
246 | 261 | ||
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 1340c93aa619..850c6d293f46 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -292,9 +292,10 @@ static size_t hist_entry_callchain__fprintf(struct hist_entry *he, | |||
292 | 292 | ||
293 | static size_t hist_entry__callchain_fprintf(struct hist_entry *he, | 293 | static size_t hist_entry__callchain_fprintf(struct hist_entry *he, |
294 | struct hists *hists, | 294 | struct hists *hists, |
295 | u64 total_period, FILE *fp) | 295 | FILE *fp) |
296 | { | 296 | { |
297 | int left_margin = 0; | 297 | int left_margin = 0; |
298 | u64 total_period = hists->stats.total_period; | ||
298 | 299 | ||
299 | if (sort__first_dimension == SORT_COMM) { | 300 | if (sort__first_dimension == SORT_COMM) { |
300 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, | 301 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, |
@@ -307,14 +308,13 @@ static size_t hist_entry__callchain_fprintf(struct hist_entry *he, | |||
307 | } | 308 | } |
308 | 309 | ||
309 | static int hist_entry__fprintf(struct hist_entry *he, size_t size, | 310 | static int hist_entry__fprintf(struct hist_entry *he, size_t size, |
310 | struct hists *hists, u64 total_period, FILE *fp) | 311 | struct hists *hists, FILE *fp) |
311 | { | 312 | { |
312 | char bf[512]; | 313 | char bf[512]; |
313 | int ret; | 314 | int ret; |
314 | struct perf_hpp hpp = { | 315 | struct perf_hpp hpp = { |
315 | .buf = bf, | 316 | .buf = bf, |
316 | .size = size, | 317 | .size = size, |
317 | .total_period = total_period, | ||
318 | }; | 318 | }; |
319 | bool color = !symbol_conf.field_sep; | 319 | bool color = !symbol_conf.field_sep; |
320 | 320 | ||
@@ -327,8 +327,7 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, | |||
327 | ret = fprintf(fp, "%s\n", bf); | 327 | ret = fprintf(fp, "%s\n", bf); |
328 | 328 | ||
329 | if (symbol_conf.use_callchain) | 329 | if (symbol_conf.use_callchain) |
330 | ret += hist_entry__callchain_fprintf(he, hists, | 330 | ret += hist_entry__callchain_fprintf(he, hists, fp); |
331 | total_period, fp); | ||
332 | 331 | ||
333 | return ret; | 332 | return ret; |
334 | } | 333 | } |
@@ -339,7 +338,6 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
339 | struct sort_entry *se; | 338 | struct sort_entry *se; |
340 | struct rb_node *nd; | 339 | struct rb_node *nd; |
341 | size_t ret = 0; | 340 | size_t ret = 0; |
342 | u64 total_period; | ||
343 | unsigned int width; | 341 | unsigned int width; |
344 | const char *sep = symbol_conf.field_sep; | 342 | const char *sep = symbol_conf.field_sep; |
345 | const char *col_width = symbol_conf.col_width_list_str; | 343 | const char *col_width = symbol_conf.col_width_list_str; |
@@ -441,16 +439,13 @@ size_t hists__fprintf(struct hists *hists, bool show_header, int max_rows, | |||
441 | goto out; | 439 | goto out; |
442 | 440 | ||
443 | print_entries: | 441 | print_entries: |
444 | total_period = hists->stats.total_period; | ||
445 | |||
446 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 442 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
447 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | 443 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); |
448 | 444 | ||
449 | if (h->filtered) | 445 | if (h->filtered) |
450 | continue; | 446 | continue; |
451 | 447 | ||
452 | ret += hist_entry__fprintf(h, max_cols, hists, | 448 | ret += hist_entry__fprintf(h, max_cols, hists, fp); |
453 | total_period, fp); | ||
454 | 449 | ||
455 | if (max_rows && ++nr_rows >= max_rows) | 450 | if (max_rows && ++nr_rows >= max_rows) |
456 | goto out; | 451 | goto out; |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index a7f69d69dc66..66cb31fe81d2 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -117,7 +117,6 @@ void hists__calc_col_len(struct hists *hists, struct hist_entry *he); | |||
117 | struct perf_hpp { | 117 | struct perf_hpp { |
118 | char *buf; | 118 | char *buf; |
119 | size_t size; | 119 | size_t size; |
120 | u64 total_period; | ||
121 | const char *sep; | 120 | const char *sep; |
122 | void *ptr; | 121 | void *ptr; |
123 | }; | 122 | }; |