aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@redhat.com>2012-10-04 08:49:37 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-04 12:28:49 -0400
commit5395a04841fcdd9220177f2c21353fe6d4cd0729 (patch)
tree5a382c4664dcda284c3aa963eca28148b419cb41 /tools/perf
parentdd464345f330c1103f93daad309e8b44845e96cf (diff)
perf hists: Separate overhead and baseline columns
Currently the overhead and baseline columns are handled within single function and the distinction is made by 'baseline hists' pointer passed by 'struct perf_hpp::ptr'. Since hists pointer is now part of each hist_entry, it's possible to locate paired hists pointer directly from the passed struct hist_entry pointer. Also separating those 2 columns makes the code more obvious. 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@elte.hu> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/r/1349354994-17853-4-git-send-email-namhyung@kernel.org Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/ui/hist.c74
-rw-r--r--tools/perf/ui/stdio/hist.c11
-rw-r--r--tools/perf/util/hist.h1
3 files changed, 58 insertions, 28 deletions
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c
index 55b9ca8f084c..532a60177c32 100644
--- a/tools/perf/ui/hist.c
+++ b/tools/perf/ui/hist.c
@@ -8,9 +8,7 @@
8/* hist period print (hpp) functions */ 8/* hist period print (hpp) functions */
9static int hpp__header_overhead(struct perf_hpp *hpp) 9static int hpp__header_overhead(struct perf_hpp *hpp)
10{ 10{
11 const char *fmt = hpp->ptr ? "Baseline" : "Overhead"; 11 return scnprintf(hpp->buf, hpp->size, "Overhead");
12
13 return scnprintf(hpp->buf, hpp->size, fmt);
14} 12}
15 13
16static int hpp__width_overhead(struct perf_hpp *hpp __maybe_unused) 14static int hpp__width_overhead(struct perf_hpp *hpp __maybe_unused)
@@ -22,17 +20,6 @@ static int hpp__color_overhead(struct perf_hpp *hpp, struct hist_entry *he)
22{ 20{
23 double percent = 100.0 * he->period / hpp->total_period; 21 double percent = 100.0 * he->period / hpp->total_period;
24 22
25 if (hpp->ptr) {
26 struct hists *old_hists = hpp->ptr;
27 u64 total_period = old_hists->stats.total_period;
28 u64 base_period = he->pair ? he->pair->period : 0;
29
30 if (total_period)
31 percent = 100.0 * base_period / total_period;
32 else
33 percent = 0.0;
34 }
35
36 return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent); 23 return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent);
37} 24}
38 25
@@ -41,17 +28,6 @@ static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he)
41 double percent = 100.0 * he->period / hpp->total_period; 28 double percent = 100.0 * he->period / hpp->total_period;
42 const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%"; 29 const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%";
43 30
44 if (hpp->ptr) {
45 struct hists *old_hists = hpp->ptr;
46 u64 total_period = old_hists->stats.total_period;
47 u64 base_period = he->pair ? he->pair->period : 0;
48
49 if (total_period)
50 percent = 100.0 * base_period / total_period;
51 else
52 percent = 0.0;
53 }
54
55 return scnprintf(hpp->buf, hpp->size, fmt, percent); 31 return scnprintf(hpp->buf, hpp->size, fmt, percent);
56} 32}
57 33
@@ -159,6 +135,47 @@ static int hpp__entry_overhead_guest_us(struct perf_hpp *hpp,
159 return scnprintf(hpp->buf, hpp->size, fmt, percent); 135 return scnprintf(hpp->buf, hpp->size, fmt, percent);
160} 136}
161 137
138static int hpp__header_baseline(struct perf_hpp *hpp)
139{
140 return scnprintf(hpp->buf, hpp->size, "Baseline");
141}
142
143static int hpp__width_baseline(struct perf_hpp *hpp __maybe_unused)
144{
145 return 8;
146}
147
148static double baseline_percent(struct hist_entry *he)
149{
150 struct hist_entry *pair = he->pair;
151 struct hists *pair_hists = pair ? pair->hists : NULL;
152 double percent = 0.0;
153
154 if (pair) {
155 u64 total_period = pair_hists->stats.total_period;
156 u64 base_period = pair->period;
157
158 percent = 100.0 * base_period / total_period;
159 }
160
161 return percent;
162}
163
164static int hpp__color_baseline(struct perf_hpp *hpp, struct hist_entry *he)
165{
166 double percent = baseline_percent(he);
167
168 return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent);
169}
170
171static int hpp__entry_baseline(struct perf_hpp *hpp, struct hist_entry *he)
172{
173 double percent = baseline_percent(he);
174 const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%";
175
176 return scnprintf(hpp->buf, hpp->size, fmt, percent);
177}
178
162static int hpp__header_samples(struct perf_hpp *hpp) 179static int hpp__header_samples(struct perf_hpp *hpp)
163{ 180{
164 const char *fmt = symbol_conf.field_sep ? "%s" : "%11s"; 181 const char *fmt = symbol_conf.field_sep ? "%s" : "%11s";
@@ -269,6 +286,7 @@ static int hpp__entry_displ(struct perf_hpp *hpp,
269 .entry = hpp__entry_ ## _name 286 .entry = hpp__entry_ ## _name
270 287
271struct perf_hpp_fmt perf_hpp__format[] = { 288struct perf_hpp_fmt perf_hpp__format[] = {
289 { .cond = false, HPP__COLOR_PRINT_FNS(baseline) },
272 { .cond = true, HPP__COLOR_PRINT_FNS(overhead) }, 290 { .cond = true, HPP__COLOR_PRINT_FNS(overhead) },
273 { .cond = false, HPP__COLOR_PRINT_FNS(overhead_sys) }, 291 { .cond = false, HPP__COLOR_PRINT_FNS(overhead_sys) },
274 { .cond = false, HPP__COLOR_PRINT_FNS(overhead_us) }, 292 { .cond = false, HPP__COLOR_PRINT_FNS(overhead_us) },
@@ -302,6 +320,8 @@ void perf_hpp__init(bool need_pair, bool show_displacement)
302 perf_hpp__format[PERF_HPP__PERIOD].cond = true; 320 perf_hpp__format[PERF_HPP__PERIOD].cond = true;
303 321
304 if (need_pair) { 322 if (need_pair) {
323 perf_hpp__format[PERF_HPP__OVERHEAD].cond = false;
324 perf_hpp__format[PERF_HPP__BASELINE].cond = true;
305 perf_hpp__format[PERF_HPP__DELTA].cond = true; 325 perf_hpp__format[PERF_HPP__DELTA].cond = true;
306 326
307 if (show_displacement) 327 if (show_displacement)
@@ -321,6 +341,7 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
321 const char *sep = symbol_conf.field_sep; 341 const char *sep = symbol_conf.field_sep;
322 char *start = hpp->buf; 342 char *start = hpp->buf;
323 int i, ret; 343 int i, ret;
344 bool first = true;
324 345
325 if (symbol_conf.exclude_other && !he->parent) 346 if (symbol_conf.exclude_other && !he->parent)
326 return 0; 347 return 0;
@@ -329,9 +350,10 @@ int hist_entry__period_snprintf(struct perf_hpp *hpp, struct hist_entry *he,
329 if (!perf_hpp__format[i].cond) 350 if (!perf_hpp__format[i].cond)
330 continue; 351 continue;
331 352
332 if (!sep || i > 0) { 353 if (!sep || !first) {
333 ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " "); 354 ret = scnprintf(hpp->buf, hpp->size, "%s", sep ?: " ");
334 advance_hpp(hpp, ret); 355 advance_hpp(hpp, ret);
356 first = false;
335 } 357 }
336 358
337 if (color && perf_hpp__format[i].color) 359 if (color && perf_hpp__format[i].color)
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c
index d7405f064e88..0aa6776caba5 100644
--- a/tools/perf/ui/stdio/hist.c
+++ b/tools/perf/ui/stdio/hist.c
@@ -353,6 +353,7 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
353 .size = sizeof(bf), 353 .size = sizeof(bf),
354 .ptr = pair, 354 .ptr = pair,
355 }; 355 };
356 bool first = true;
356 357
357 init_rem_hits(); 358 init_rem_hits();
358 359
@@ -364,8 +365,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
364 if (!perf_hpp__format[idx].cond) 365 if (!perf_hpp__format[idx].cond)
365 continue; 366 continue;
366 367
367 if (idx) 368 if (!first)
368 fprintf(fp, "%s", sep ?: " "); 369 fprintf(fp, "%s", sep ?: " ");
370 else
371 first = false;
369 372
370 perf_hpp__format[idx].header(&dummy_hpp); 373 perf_hpp__format[idx].header(&dummy_hpp);
371 fprintf(fp, "%s", bf); 374 fprintf(fp, "%s", bf);
@@ -400,6 +403,8 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
400 if (sep) 403 if (sep)
401 goto print_entries; 404 goto print_entries;
402 405
406 first = true;
407
403 fprintf(fp, "# "); 408 fprintf(fp, "# ");
404 for (idx = 0; idx < PERF_HPP__MAX_INDEX; idx++) { 409 for (idx = 0; idx < PERF_HPP__MAX_INDEX; idx++) {
405 unsigned int i; 410 unsigned int i;
@@ -407,8 +412,10 @@ size_t hists__fprintf(struct hists *hists, struct hists *pair,
407 if (!perf_hpp__format[idx].cond) 412 if (!perf_hpp__format[idx].cond)
408 continue; 413 continue;
409 414
410 if (idx) 415 if (!first)
411 fprintf(fp, "%s", sep ?: " "); 416 fprintf(fp, "%s", sep ?: " ");
417 else
418 first = false;
412 419
413 width = perf_hpp__format[idx].width(&dummy_hpp); 420 width = perf_hpp__format[idx].width(&dummy_hpp);
414 for (i = 0; i < width; i++) 421 for (i = 0; i < width; i++)
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index efb8fc8a4d24..b1a2b9d9b658 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -133,6 +133,7 @@ struct perf_hpp_fmt {
133extern struct perf_hpp_fmt perf_hpp__format[]; 133extern struct perf_hpp_fmt perf_hpp__format[];
134 134
135enum { 135enum {
136 PERF_HPP__BASELINE,
136 PERF_HPP__OVERHEAD, 137 PERF_HPP__OVERHEAD,
137 PERF_HPP__OVERHEAD_SYS, 138 PERF_HPP__OVERHEAD_SYS,
138 PERF_HPP__OVERHEAD_US, 139 PERF_HPP__OVERHEAD_US,