aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-10-18 12:37:34 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-10-18 15:03:08 -0400
commitf1cf602c16e9a93fd16705621f3430ec7ffe2c44 (patch)
tree3f31d1a6fdca87b11375245efcb79c139f0c4733 /tools
parentc172f7422c03463a7177e268ffe625c41c42c179 (diff)
perf hists: Don't format the percentage on hist_entry__snprintf
We can't have color correctly set there because in libslang (and in a future GUI) the colors must be set on a separate function call, so move that part to a separate function and make the stdio fprintf function call it. Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-jpgy42438ce9tgbqppm397lq@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/hist.c29
-rw-r--r--tools/perf/util/hist.h4
-rw-r--r--tools/perf/util/ui/browsers/hists.c7
3 files changed, 25 insertions, 15 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c
index 48da373afa3..8d15e9f72f0 100644
--- a/tools/perf/util/hist.c
+++ b/tools/perf/util/hist.c
@@ -707,12 +707,11 @@ void hists__output_recalc_col_len(struct hists *hists, int max_rows)
707 } 707 }
708} 708}
709 709
710int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size, 710static int hist_entry__pcnt_snprintf(struct hist_entry *self, char *s,
711 struct hists *hists, struct hists *pair_hists, 711 size_t size, struct hists *pair_hists,
712 bool show_displacement, long displacement, 712 bool show_displacement, long displacement,
713 bool color, u64 session_total) 713 bool color, u64 session_total)
714{ 714{
715 struct sort_entry *se;
716 u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us; 715 u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us;
717 u64 nr_events; 716 u64 nr_events;
718 const char *sep = symbol_conf.field_sep; 717 const char *sep = symbol_conf.field_sep;
@@ -818,12 +817,22 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
818 } 817 }
819 } 818 }
820 819
820 return ret;
821}
822
823int hist_entry__snprintf(struct hist_entry *he, char *s, size_t size,
824 struct hists *hists)
825{
826 const char *sep = symbol_conf.field_sep;
827 struct sort_entry *se;
828 int ret = 0;
829
821 list_for_each_entry(se, &hist_entry__sort_list, list) { 830 list_for_each_entry(se, &hist_entry__sort_list, list) {
822 if (se->elide) 831 if (se->elide)
823 continue; 832 continue;
824 833
825 ret += snprintf(s + ret, size - ret, "%s", sep ?: " "); 834 ret += snprintf(s + ret, size - ret, "%s", sep ?: " ");
826 ret += se->se_snprintf(self, s + ret, size - ret, 835 ret += se->se_snprintf(he, s + ret, size - ret,
827 hists__col_len(hists, se->se_width_idx)); 836 hists__col_len(hists, se->se_width_idx));
828 } 837 }
829 838
@@ -835,13 +844,15 @@ int hist_entry__fprintf(struct hist_entry *he, size_t size, struct hists *hists,
835 long displacement, FILE *fp, u64 session_total) 844 long displacement, FILE *fp, u64 session_total)
836{ 845{
837 char bf[512]; 846 char bf[512];
847 int ret;
838 848
839 if (size == 0 || size > sizeof(bf)) 849 if (size == 0 || size > sizeof(bf))
840 size = sizeof(bf); 850 size = sizeof(bf);
841 851
842 hist_entry__snprintf(he, bf, size, hists, pair_hists, 852 ret = hist_entry__pcnt_snprintf(he, bf, size, pair_hists,
843 show_displacement, displacement, 853 show_displacement, displacement,
844 true, session_total); 854 true, session_total);
855 hist_entry__snprintf(he, bf + ret, size - ret, hists);
845 return fprintf(fp, "%s\n", bf); 856 return fprintf(fp, "%s\n", bf);
846} 857}
847 858
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h
index ea96c1cbb85..f338cb02567 100644
--- a/tools/perf/util/hist.h
+++ b/tools/perf/util/hist.h
@@ -68,9 +68,7 @@ int hist_entry__fprintf(struct hist_entry *he, size_t size, struct hists *hists,
68 struct hists *pair_hists, bool show_displacement, 68 struct hists *pair_hists, bool show_displacement,
69 long displacement, FILE *fp, u64 session_total); 69 long displacement, FILE *fp, u64 session_total);
70int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size, 70int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size,
71 struct hists *hists, struct hists *pair_hists, 71 struct hists *hists);
72 bool show_displacement, long displacement,
73 bool color, u64 total);
74void hist_entry__free(struct hist_entry *); 72void hist_entry__free(struct hist_entry *);
75 73
76void hists__output_resort(struct hists *self); 74void hists__output_resort(struct hists *self);
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c
index 2d390b9cb63..0eced19e3bd 100644
--- a/tools/perf/util/ui/browsers/hists.c
+++ b/tools/perf/util/ui/browsers/hists.c
@@ -547,7 +547,7 @@ static int hist_browser__show_entry(struct hist_browser *self,
547 char s[256]; 547 char s[256];
548 double percent; 548 double percent;
549 int printed = 0; 549 int printed = 0;
550 int width = self->b.width; 550 int width = self->b.width - 6; /* The percentage */
551 char folded_sign = ' '; 551 char folded_sign = ' ';
552 bool current_entry = ui_browser__is_current_entry(&self->b, row); 552 bool current_entry = ui_browser__is_current_entry(&self->b, row);
553 off_t row_offset = entry->row_offset; 553 off_t row_offset = entry->row_offset;
@@ -563,8 +563,7 @@ static int hist_browser__show_entry(struct hist_browser *self,
563 } 563 }
564 564
565 if (row_offset == 0) { 565 if (row_offset == 0) {
566 hist_entry__snprintf(entry, s, sizeof(s), self->hists, NULL, false, 566 hist_entry__snprintf(entry, s, sizeof(s), self->hists);
567 0, false, self->hists->stats.total_period);
568 percent = (entry->period * 100.0) / self->hists->stats.total_period; 567 percent = (entry->period * 100.0) / self->hists->stats.total_period;
569 568
570 ui_browser__set_percent_color(&self->b, percent, current_entry); 569 ui_browser__set_percent_color(&self->b, percent, current_entry);
@@ -574,6 +573,8 @@ static int hist_browser__show_entry(struct hist_browser *self,
574 width -= 2; 573 width -= 2;
575 } 574 }
576 575
576 slsmg_printf(" %5.2f%%", percent);
577
577 /* The scroll bar isn't being used */ 578 /* The scroll bar isn't being used */
578 if (!self->b.navkeypressed) 579 if (!self->b.navkeypressed)
579 width += 1; 580 width += 1;