diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-07-31 01:47:40 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-08-12 11:03:07 -0400 |
commit | 1ecd44533a8a724f64d4305abb69836ca73c7390 (patch) | |
tree | 97ad0b838e970ba2a3fd9511de85ce9e2a918246 /tools/perf/ui | |
parent | cf59002fdebc9c00ee29233e65bc39dd69e0eaf6 (diff) |
perf tools: Add name field into perf_hpp_fmt
It makes the code a bit simpler and easier to debug IMHO.
I guess it can also remove similar code in perf diff, but let's keep
it for a future work. :)
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung.kim@lge.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1406785662-5534-7-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui')
-rw-r--r-- | tools/perf/ui/gtk/hists.c | 4 | ||||
-rw-r--r-- | tools/perf/ui/hist.c | 136 |
2 files changed, 62 insertions, 78 deletions
diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c index 897b2e140428..f3fa4258b256 100644 --- a/tools/perf/ui/gtk/hists.c +++ b/tools/perf/ui/gtk/hists.c | |||
@@ -207,10 +207,8 @@ static void perf_gtk__show_hists(GtkWidget *window, struct hists *hists, | |||
207 | if (perf_hpp__is_sort_entry(fmt)) | 207 | if (perf_hpp__is_sort_entry(fmt)) |
208 | sym_col = col_idx; | 208 | sym_col = col_idx; |
209 | 209 | ||
210 | fmt->header(fmt, &hpp, hists_to_evsel(hists)); | ||
211 | |||
212 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), | 210 | gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), |
213 | -1, ltrim(s), | 211 | -1, fmt->name, |
214 | renderer, "markup", | 212 | renderer, "markup", |
215 | col_idx++, NULL); | 213 | col_idx++, NULL); |
216 | } | 214 | } |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index b2d60a95f01d..b5fa7019d2e2 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
@@ -209,29 +209,26 @@ static int __hpp__sort_acc(struct hist_entry *a, struct hist_entry *b, | |||
209 | return ret; | 209 | return ret; |
210 | } | 210 | } |
211 | 211 | ||
212 | #define __HPP_WIDTH_FN(_type, _str) \ | 212 | static int hpp__width_fn(struct perf_hpp_fmt *fmt, |
213 | static int hpp__width_##_type(struct perf_hpp_fmt *fmt, \ | 213 | struct perf_hpp *hpp __maybe_unused, |
214 | struct perf_hpp *hpp __maybe_unused, \ | 214 | struct perf_evsel *evsel) |
215 | struct perf_evsel *evsel) \ | 215 | { |
216 | { \ | 216 | int len = fmt->user_len ?: fmt->len; |
217 | int len = fmt->user_len ?: fmt->len; \ | 217 | |
218 | \ | 218 | if (symbol_conf.event_group) |
219 | if (symbol_conf.event_group) \ | 219 | len = max(len, evsel->nr_members * fmt->len); |
220 | len = max(len, evsel->nr_members * fmt->len); \ | 220 | |
221 | \ | 221 | if (len < (int)strlen(fmt->name)) |
222 | if (len < (int)strlen(_str)) \ | 222 | len = strlen(fmt->name); |
223 | len = strlen(_str); \ | 223 | |
224 | \ | 224 | return len; |
225 | return len; \ | 225 | } |
226 | } | 226 | |
227 | 227 | static int hpp__header_fn(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, | |
228 | #define __HPP_HEADER_FN(_type, _str) \ | 228 | struct perf_evsel *evsel) |
229 | static int hpp__header_##_type(struct perf_hpp_fmt *fmt, \ | 229 | { |
230 | struct perf_hpp *hpp, \ | 230 | int len = hpp__width_fn(fmt, hpp, evsel); |
231 | struct perf_evsel *evsel) \ | 231 | return scnprintf(hpp->buf, hpp->size, "%*s", len, fmt->name); |
232 | { \ | ||
233 | int len = hpp__width_##_type(fmt, hpp, evsel); \ | ||
234 | return scnprintf(hpp->buf, hpp->size, "%*s", len, _str); \ | ||
235 | } | 232 | } |
236 | 233 | ||
237 | static int hpp_color_scnprintf(struct perf_hpp *hpp, const char *fmt, ...) | 234 | static int hpp_color_scnprintf(struct perf_hpp *hpp, const char *fmt, ...) |
@@ -337,38 +334,29 @@ static int64_t hpp__sort_##_type(struct hist_entry *a, struct hist_entry *b) \ | |||
337 | } | 334 | } |
338 | 335 | ||
339 | 336 | ||
340 | #define HPP_PERCENT_FNS(_type, _str, _field) \ | 337 | #define HPP_PERCENT_FNS(_type, _field) \ |
341 | __HPP_WIDTH_FN(_type, _str) \ | ||
342 | __HPP_HEADER_FN(_type, _str) \ | ||
343 | __HPP_COLOR_PERCENT_FN(_type, _field) \ | 338 | __HPP_COLOR_PERCENT_FN(_type, _field) \ |
344 | __HPP_ENTRY_PERCENT_FN(_type, _field) \ | 339 | __HPP_ENTRY_PERCENT_FN(_type, _field) \ |
345 | __HPP_SORT_FN(_type, _field) | 340 | __HPP_SORT_FN(_type, _field) |
346 | 341 | ||
347 | #define HPP_PERCENT_ACC_FNS(_type, _str, _field) \ | 342 | #define HPP_PERCENT_ACC_FNS(_type, _field) \ |
348 | __HPP_WIDTH_FN(_type, _str) \ | ||
349 | __HPP_HEADER_FN(_type, _str) \ | ||
350 | __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ | 343 | __HPP_COLOR_ACC_PERCENT_FN(_type, _field) \ |
351 | __HPP_ENTRY_ACC_PERCENT_FN(_type, _field) \ | 344 | __HPP_ENTRY_ACC_PERCENT_FN(_type, _field) \ |
352 | __HPP_SORT_ACC_FN(_type, _field) | 345 | __HPP_SORT_ACC_FN(_type, _field) |
353 | 346 | ||
354 | #define HPP_RAW_FNS(_type, _str, _field) \ | 347 | #define HPP_RAW_FNS(_type, _field) \ |
355 | __HPP_WIDTH_FN(_type, _str) \ | ||
356 | __HPP_HEADER_FN(_type, _str) \ | ||
357 | __HPP_ENTRY_RAW_FN(_type, _field) \ | 348 | __HPP_ENTRY_RAW_FN(_type, _field) \ |
358 | __HPP_SORT_RAW_FN(_type, _field) | 349 | __HPP_SORT_RAW_FN(_type, _field) |
359 | 350 | ||
360 | __HPP_WIDTH_FN(overhead_self, "Self") | 351 | HPP_PERCENT_FNS(overhead, period) |
361 | __HPP_HEADER_FN(overhead_self, "Self") | 352 | HPP_PERCENT_FNS(overhead_sys, period_sys) |
353 | HPP_PERCENT_FNS(overhead_us, period_us) | ||
354 | HPP_PERCENT_FNS(overhead_guest_sys, period_guest_sys) | ||
355 | HPP_PERCENT_FNS(overhead_guest_us, period_guest_us) | ||
356 | HPP_PERCENT_ACC_FNS(overhead_acc, period) | ||
362 | 357 | ||
363 | HPP_PERCENT_FNS(overhead, "Overhead", period) | 358 | HPP_RAW_FNS(samples, nr_events) |
364 | HPP_PERCENT_FNS(overhead_sys, "sys", period_sys) | 359 | HPP_RAW_FNS(period, period) |
365 | HPP_PERCENT_FNS(overhead_us, "usr", period_us) | ||
366 | HPP_PERCENT_FNS(overhead_guest_sys, "guest sys", period_guest_sys) | ||
367 | HPP_PERCENT_FNS(overhead_guest_us, "guest usr", period_guest_us) | ||
368 | HPP_PERCENT_ACC_FNS(overhead_acc, "Children", period) | ||
369 | |||
370 | HPP_RAW_FNS(samples, "Samples", nr_events) | ||
371 | HPP_RAW_FNS(period, "Period", period) | ||
372 | 360 | ||
373 | static int64_t hpp__nop_cmp(struct hist_entry *a __maybe_unused, | 361 | static int64_t hpp__nop_cmp(struct hist_entry *a __maybe_unused, |
374 | struct hist_entry *b __maybe_unused) | 362 | struct hist_entry *b __maybe_unused) |
@@ -376,47 +364,50 @@ static int64_t hpp__nop_cmp(struct hist_entry *a __maybe_unused, | |||
376 | return 0; | 364 | return 0; |
377 | } | 365 | } |
378 | 366 | ||
379 | #define HPP__COLOR_PRINT_FNS(_name) \ | 367 | #define HPP__COLOR_PRINT_FNS(_name, _fn) \ |
380 | { \ | 368 | { \ |
381 | .header = hpp__header_ ## _name, \ | 369 | .name = _name, \ |
382 | .width = hpp__width_ ## _name, \ | 370 | .header = hpp__header_fn, \ |
383 | .color = hpp__color_ ## _name, \ | 371 | .width = hpp__width_fn, \ |
384 | .entry = hpp__entry_ ## _name, \ | 372 | .color = hpp__color_ ## _fn, \ |
373 | .entry = hpp__entry_ ## _fn, \ | ||
385 | .cmp = hpp__nop_cmp, \ | 374 | .cmp = hpp__nop_cmp, \ |
386 | .collapse = hpp__nop_cmp, \ | 375 | .collapse = hpp__nop_cmp, \ |
387 | .sort = hpp__sort_ ## _name, \ | 376 | .sort = hpp__sort_ ## _fn, \ |
388 | } | 377 | } |
389 | 378 | ||
390 | #define HPP__COLOR_ACC_PRINT_FNS(_name) \ | 379 | #define HPP__COLOR_ACC_PRINT_FNS(_name, _fn) \ |
391 | { \ | 380 | { \ |
392 | .header = hpp__header_ ## _name, \ | 381 | .name = _name, \ |
393 | .width = hpp__width_ ## _name, \ | 382 | .header = hpp__header_fn, \ |
394 | .color = hpp__color_ ## _name, \ | 383 | .width = hpp__width_fn, \ |
395 | .entry = hpp__entry_ ## _name, \ | 384 | .color = hpp__color_ ## _fn, \ |
385 | .entry = hpp__entry_ ## _fn, \ | ||
396 | .cmp = hpp__nop_cmp, \ | 386 | .cmp = hpp__nop_cmp, \ |
397 | .collapse = hpp__nop_cmp, \ | 387 | .collapse = hpp__nop_cmp, \ |
398 | .sort = hpp__sort_ ## _name, \ | 388 | .sort = hpp__sort_ ## _fn, \ |
399 | } | 389 | } |
400 | 390 | ||
401 | #define HPP__PRINT_FNS(_name) \ | 391 | #define HPP__PRINT_FNS(_name, _fn) \ |
402 | { \ | 392 | { \ |
403 | .header = hpp__header_ ## _name, \ | 393 | .name = _name, \ |
404 | .width = hpp__width_ ## _name, \ | 394 | .header = hpp__header_fn, \ |
405 | .entry = hpp__entry_ ## _name, \ | 395 | .width = hpp__width_fn, \ |
396 | .entry = hpp__entry_ ## _fn, \ | ||
406 | .cmp = hpp__nop_cmp, \ | 397 | .cmp = hpp__nop_cmp, \ |
407 | .collapse = hpp__nop_cmp, \ | 398 | .collapse = hpp__nop_cmp, \ |
408 | .sort = hpp__sort_ ## _name, \ | 399 | .sort = hpp__sort_ ## _fn, \ |
409 | } | 400 | } |
410 | 401 | ||
411 | struct perf_hpp_fmt perf_hpp__format[] = { | 402 | struct perf_hpp_fmt perf_hpp__format[] = { |
412 | HPP__COLOR_PRINT_FNS(overhead), | 403 | HPP__COLOR_PRINT_FNS("Overhead", overhead), |
413 | HPP__COLOR_PRINT_FNS(overhead_sys), | 404 | HPP__COLOR_PRINT_FNS("sys", overhead_sys), |
414 | HPP__COLOR_PRINT_FNS(overhead_us), | 405 | HPP__COLOR_PRINT_FNS("usr", overhead_us), |
415 | HPP__COLOR_PRINT_FNS(overhead_guest_sys), | 406 | HPP__COLOR_PRINT_FNS("guest sys", overhead_guest_sys), |
416 | HPP__COLOR_PRINT_FNS(overhead_guest_us), | 407 | HPP__COLOR_PRINT_FNS("guest usr", overhead_guest_us), |
417 | HPP__COLOR_ACC_PRINT_FNS(overhead_acc), | 408 | HPP__COLOR_ACC_PRINT_FNS("Children", overhead_acc), |
418 | HPP__PRINT_FNS(samples), | 409 | HPP__PRINT_FNS("Samples", samples), |
419 | HPP__PRINT_FNS(period) | 410 | HPP__PRINT_FNS("Period", period) |
420 | }; | 411 | }; |
421 | 412 | ||
422 | LIST_HEAD(perf_hpp__list); | 413 | LIST_HEAD(perf_hpp__list); |
@@ -466,11 +457,7 @@ void perf_hpp__init(void) | |||
466 | 457 | ||
467 | if (symbol_conf.cumulate_callchain) { | 458 | if (symbol_conf.cumulate_callchain) { |
468 | perf_hpp__column_enable(PERF_HPP__OVERHEAD_ACC); | 459 | perf_hpp__column_enable(PERF_HPP__OVERHEAD_ACC); |
469 | 460 | perf_hpp__format[PERF_HPP__OVERHEAD].name = "Self"; | |
470 | perf_hpp__format[PERF_HPP__OVERHEAD].header = | ||
471 | hpp__header_overhead_self; | ||
472 | perf_hpp__format[PERF_HPP__OVERHEAD].width = | ||
473 | hpp__width_overhead_self; | ||
474 | } | 461 | } |
475 | 462 | ||
476 | perf_hpp__column_enable(PERF_HPP__OVERHEAD); | 463 | perf_hpp__column_enable(PERF_HPP__OVERHEAD); |
@@ -536,8 +523,7 @@ void perf_hpp__cancel_cumulate(void) | |||
536 | return; | 523 | return; |
537 | 524 | ||
538 | perf_hpp__column_disable(PERF_HPP__OVERHEAD_ACC); | 525 | perf_hpp__column_disable(PERF_HPP__OVERHEAD_ACC); |
539 | perf_hpp__format[PERF_HPP__OVERHEAD].header = hpp__header_overhead; | 526 | perf_hpp__format[PERF_HPP__OVERHEAD].name = "Overhead"; |
540 | perf_hpp__format[PERF_HPP__OVERHEAD].width = hpp__width_overhead; | ||
541 | } | 527 | } |
542 | 528 | ||
543 | void perf_hpp__setup_output_field(void) | 529 | void perf_hpp__setup_output_field(void) |