diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-08-20 00:52:06 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-20 08:47:31 -0400 |
commit | 000078bc3ee69efb1124b8478c7527389a826074 (patch) | |
tree | 461ee7c8afc8db8fc6de66f4da82c41575f84202 | |
parent | 7ccf4f9058ecff6eec11a271001d08d9024da8c0 (diff) |
perf hists: Rename and move some functions
Rename functions for consistency and move callchain print function
into hist_entry__fprintf().
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1345438331-20234-3-git-send-email-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/stdio/hist.c | 51 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 4 |
3 files changed, 32 insertions, 27 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index b8094692c153..81bd8c2af730 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
@@ -586,7 +586,7 @@ static int hist_browser__show_entry(struct hist_browser *browser, | |||
586 | } | 586 | } |
587 | 587 | ||
588 | if (row_offset == 0) { | 588 | if (row_offset == 0) { |
589 | hist_entry__snprintf(entry, s, sizeof(s), browser->hists); | 589 | hist_entry__sort_snprintf(entry, s, sizeof(s), browser->hists); |
590 | percent = (entry->period * 100.0) / browser->hists->stats.total_period; | 590 | percent = (entry->period * 100.0) / browser->hists->stats.total_period; |
591 | 591 | ||
592 | ui_browser__set_percent_color(&browser->b, percent, current_entry); | 592 | ui_browser__set_percent_color(&browser->b, percent, current_entry); |
@@ -931,7 +931,7 @@ static int hist_browser__fprintf_entry(struct hist_browser *browser, | |||
931 | if (symbol_conf.use_callchain) | 931 | if (symbol_conf.use_callchain) |
932 | folded_sign = hist_entry__folded(he); | 932 | folded_sign = hist_entry__folded(he); |
933 | 933 | ||
934 | hist_entry__snprintf(he, s, sizeof(s), browser->hists); | 934 | hist_entry__sort_snprintf(he, s, sizeof(s), browser->hists); |
935 | percent = (he->period * 100.0) / browser->hists->stats.total_period; | 935 | percent = (he->period * 100.0) / browser->hists->stats.total_period; |
936 | 936 | ||
937 | if (symbol_conf.use_callchain) | 937 | if (symbol_conf.use_callchain) |
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 7881d625e17a..9bf7e9e5a72e 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -291,7 +291,7 @@ static size_t hist_entry_callchain__fprintf(struct hist_entry *he, | |||
291 | return 0; | 291 | return 0; |
292 | } | 292 | } |
293 | 293 | ||
294 | static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s, | 294 | static int hist_entry__period_snprintf(struct hist_entry *he, char *s, |
295 | size_t size, struct hists *pair_hists, | 295 | size_t size, struct hists *pair_hists, |
296 | bool show_displacement, long displacement, | 296 | bool show_displacement, long displacement, |
297 | bool color, u64 total_period) | 297 | bool color, u64 total_period) |
@@ -404,8 +404,8 @@ static int hist_entry__pcnt_snprintf(struct hist_entry *he, char *s, | |||
404 | return ret; | 404 | return ret; |
405 | } | 405 | } |
406 | 406 | ||
407 | int hist_entry__snprintf(struct hist_entry *he, char *s, size_t size, | 407 | int hist_entry__sort_snprintf(struct hist_entry *he, char *s, size_t size, |
408 | struct hists *hists) | 408 | struct hists *hists) |
409 | { | 409 | { |
410 | const char *sep = symbol_conf.field_sep; | 410 | const char *sep = symbol_conf.field_sep; |
411 | struct sort_entry *se; | 411 | struct sort_entry *se; |
@@ -423,6 +423,22 @@ int hist_entry__snprintf(struct hist_entry *he, char *s, size_t size, | |||
423 | return ret; | 423 | return ret; |
424 | } | 424 | } |
425 | 425 | ||
426 | static size_t hist_entry__callchain_fprintf(struct hist_entry *he, | ||
427 | struct hists *hists, | ||
428 | u64 total_period, FILE *fp) | ||
429 | { | ||
430 | int left_margin = 0; | ||
431 | |||
432 | if (sort__first_dimension == SORT_COMM) { | ||
433 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, | ||
434 | typeof(*se), list); | ||
435 | left_margin = hists__col_len(hists, se->se_width_idx); | ||
436 | left_margin -= thread__comm_len(he->thread); | ||
437 | } | ||
438 | |||
439 | return hist_entry_callchain__fprintf(he, total_period, left_margin, fp); | ||
440 | } | ||
441 | |||
426 | static int hist_entry__fprintf(struct hist_entry *he, size_t size, | 442 | static int hist_entry__fprintf(struct hist_entry *he, size_t size, |
427 | struct hists *hists, struct hists *pair_hists, | 443 | struct hists *hists, struct hists *pair_hists, |
428 | bool show_displacement, long displacement, | 444 | bool show_displacement, long displacement, |
@@ -434,27 +450,18 @@ static int hist_entry__fprintf(struct hist_entry *he, size_t size, | |||
434 | if (size == 0 || size > sizeof(bf)) | 450 | if (size == 0 || size > sizeof(bf)) |
435 | size = sizeof(bf); | 451 | size = sizeof(bf); |
436 | 452 | ||
437 | ret = hist_entry__pcnt_snprintf(he, bf, size, pair_hists, | 453 | ret = hist_entry__period_snprintf(he, bf, size, pair_hists, |
438 | show_displacement, displacement, | 454 | show_displacement, displacement, |
439 | true, total_period); | 455 | true, total_period); |
440 | hist_entry__snprintf(he, bf + ret, size - ret, hists); | 456 | hist_entry__sort_snprintf(he, bf + ret, size - ret, hists); |
441 | return fprintf(fp, "%s\n", bf); | ||
442 | } | ||
443 | 457 | ||
444 | static size_t hist_entry__fprintf_callchain(struct hist_entry *he, | 458 | ret = fprintf(fp, "%s\n", bf); |
445 | struct hists *hists, | ||
446 | u64 total_period, FILE *fp) | ||
447 | { | ||
448 | int left_margin = 0; | ||
449 | 459 | ||
450 | if (sort__first_dimension == SORT_COMM) { | 460 | if (symbol_conf.use_callchain) |
451 | struct sort_entry *se = list_first_entry(&hist_entry__sort_list, | 461 | ret += hist_entry__callchain_fprintf(he, hists, |
452 | typeof(*se), list); | 462 | total_period, fp); |
453 | left_margin = hists__col_len(hists, se->se_width_idx); | ||
454 | left_margin -= thread__comm_len(he->thread); | ||
455 | } | ||
456 | 463 | ||
457 | return hist_entry_callchain__fprintf(he, total_period, left_margin, fp); | 464 | return ret; |
458 | } | 465 | } |
459 | 466 | ||
460 | size_t hists__fprintf(struct hists *hists, struct hists *pair, | 467 | size_t hists__fprintf(struct hists *hists, struct hists *pair, |
@@ -608,8 +615,6 @@ print_entries: | |||
608 | ret += hist_entry__fprintf(h, max_cols, hists, pair, show_displacement, | 615 | ret += hist_entry__fprintf(h, max_cols, hists, pair, show_displacement, |
609 | displacement, total_period, fp); | 616 | displacement, total_period, fp); |
610 | 617 | ||
611 | if (symbol_conf.use_callchain) | ||
612 | ret += hist_entry__fprintf_callchain(h, hists, total_period, fp); | ||
613 | if (max_rows && ++nr_rows >= max_rows) | 618 | if (max_rows && ++nr_rows >= max_rows) |
614 | goto out; | 619 | goto out; |
615 | 620 | ||
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 69fab7d9abcd..2e650ffb7d23 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -75,8 +75,8 @@ struct hist_entry *__hists__add_entry(struct hists *self, | |||
75 | struct symbol *parent, u64 period); | 75 | struct symbol *parent, u64 period); |
76 | int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right); | 76 | int64_t hist_entry__cmp(struct hist_entry *left, struct hist_entry *right); |
77 | int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right); | 77 | int64_t hist_entry__collapse(struct hist_entry *left, struct hist_entry *right); |
78 | int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size, | 78 | int hist_entry__sort_snprintf(struct hist_entry *self, char *bf, size_t size, |
79 | struct hists *hists); | 79 | struct hists *hists); |
80 | void hist_entry__free(struct hist_entry *); | 80 | void hist_entry__free(struct hist_entry *); |
81 | 81 | ||
82 | struct hist_entry *__hists__add_branch_entry(struct hists *self, | 82 | struct hist_entry *__hists__add_branch_entry(struct hists *self, |