diff options
| author | Namhyung Kim <namhyung.kim@lge.com> | 2012-09-12 02:35:05 -0400 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-09-14 14:49:45 -0400 |
| commit | 721b3112f5882a6de7b86b9bef5813c80d1223de (patch) | |
| tree | 1978fe19cdb4e0832a6a36230e9c31ceed618aeb | |
| parent | c055875b7091a301e2b1107ef8914b7d24e12fb0 (diff) | |
perf hists browser: Fix output for 100.00%
Current hpp format functions assume that the output will fit to 6
character including % sign (XX.YY%) so used "%5.2f%%" as a format
string. However it might be the case if collapsing resulted in a single
entry which has 100.00% (7 character) of period. In this case the output
will be shifted by 1 character.
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/1347431706-7839-1-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 | 2 | ||||
| -rw-r--r-- | tools/perf/ui/gtk/browser.c | 2 | ||||
| -rw-r--r-- | tools/perf/ui/hist.c | 28 |
3 files changed, 16 insertions, 16 deletions
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 5a5739bbe6ac..11783170ac62 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
| @@ -571,7 +571,7 @@ static int hist_browser__hpp_color_ ## _name(struct perf_hpp *hpp, \ | |||
| 571 | { \ | 571 | { \ |
| 572 | double percent = 100.0 * he->_field / hpp->total_period; \ | 572 | double percent = 100.0 * he->_field / hpp->total_period; \ |
| 573 | *(double *)hpp->ptr = percent; \ | 573 | *(double *)hpp->ptr = percent; \ |
| 574 | return scnprintf(hpp->buf, hpp->size, "%5.2f%%", percent); \ | 574 | return scnprintf(hpp->buf, hpp->size, "%6.2f%%", percent); \ |
| 575 | } | 575 | } |
| 576 | 576 | ||
| 577 | HPP__COLOR_FN(overhead, period) | 577 | HPP__COLOR_FN(overhead, period) |
diff --git a/tools/perf/ui/gtk/browser.c b/tools/perf/ui/gtk/browser.c index 55acba6e0df4..7ff99ec1d95e 100644 --- a/tools/perf/ui/gtk/browser.c +++ b/tools/perf/ui/gtk/browser.c | |||
| @@ -56,7 +56,7 @@ static int perf_gtk__hpp_color_ ## _name(struct perf_hpp *hpp, \ | |||
| 56 | markup = perf_gtk__get_percent_color(percent); \ | 56 | markup = perf_gtk__get_percent_color(percent); \ |
| 57 | if (markup) \ | 57 | if (markup) \ |
| 58 | ret += scnprintf(hpp->buf, hpp->size, "%s", markup); \ | 58 | ret += scnprintf(hpp->buf, hpp->size, "%s", markup); \ |
| 59 | ret += scnprintf(hpp->buf + ret, hpp->size - ret, "%5.2f%%", percent); \ | 59 | ret += scnprintf(hpp->buf + ret, hpp->size - ret, "%6.2f%%", percent); \ |
| 60 | if (markup) \ | 60 | if (markup) \ |
| 61 | ret += scnprintf(hpp->buf + ret, hpp->size - ret, "</span>"); \ | 61 | ret += scnprintf(hpp->buf + ret, hpp->size - ret, "</span>"); \ |
| 62 | \ | 62 | \ |
diff --git a/tools/perf/ui/hist.c b/tools/perf/ui/hist.c index 407e855cccb8..e3f8cd46e7d7 100644 --- a/tools/perf/ui/hist.c +++ b/tools/perf/ui/hist.c | |||
| @@ -33,13 +33,13 @@ static int hpp__color_overhead(struct perf_hpp *hpp, struct hist_entry *he) | |||
| 33 | percent = 0.0; | 33 | percent = 0.0; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | return percent_color_snprintf(hpp->buf, hpp->size, " %5.2f%%", percent); | 36 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%%", percent); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he) | 39 | static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he) |
| 40 | { | 40 | { |
| 41 | double percent = 100.0 * he->period / hpp->total_period; | 41 | double percent = 100.0 * he->period / hpp->total_period; |
| 42 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %5.2f%%"; | 42 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%%"; |
| 43 | 43 | ||
| 44 | if (hpp->ptr) { | 44 | if (hpp->ptr) { |
| 45 | struct hists *old_hists = hpp->ptr; | 45 | struct hists *old_hists = hpp->ptr; |
| @@ -57,52 +57,52 @@ static int hpp__entry_overhead(struct perf_hpp *hpp, struct hist_entry *he) | |||
| 57 | 57 | ||
| 58 | static int hpp__header_overhead_sys(struct perf_hpp *hpp) | 58 | static int hpp__header_overhead_sys(struct perf_hpp *hpp) |
| 59 | { | 59 | { |
| 60 | const char *fmt = symbol_conf.field_sep ? "%s" : "%6s"; | 60 | const char *fmt = symbol_conf.field_sep ? "%s" : "%7s"; |
| 61 | 61 | ||
| 62 | return scnprintf(hpp->buf, hpp->size, fmt, "sys"); | 62 | return scnprintf(hpp->buf, hpp->size, fmt, "sys"); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | static int hpp__width_overhead_sys(struct perf_hpp *hpp __maybe_unused) | 65 | static int hpp__width_overhead_sys(struct perf_hpp *hpp __maybe_unused) |
| 66 | { | 66 | { |
| 67 | return 6; | 67 | return 7; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static int hpp__color_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he) | 70 | static int hpp__color_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he) |
| 71 | { | 71 | { |
| 72 | double percent = 100.0 * he->period_sys / hpp->total_period; | 72 | double percent = 100.0 * he->period_sys / hpp->total_period; |
| 73 | return percent_color_snprintf(hpp->buf, hpp->size, "%5.2f%%", percent); | 73 | return percent_color_snprintf(hpp->buf, hpp->size, "%6.2f%%", percent); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | static int hpp__entry_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he) | 76 | static int hpp__entry_overhead_sys(struct perf_hpp *hpp, struct hist_entry *he) |
| 77 | { | 77 | { |
| 78 | double percent = 100.0 * he->period_sys / hpp->total_period; | 78 | double percent = 100.0 * he->period_sys / hpp->total_period; |
| 79 | const char *fmt = symbol_conf.field_sep ? "%.2f" : "%5.2f%%"; | 79 | const char *fmt = symbol_conf.field_sep ? "%.2f" : "%6.2f%%"; |
| 80 | 80 | ||
| 81 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 81 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | static int hpp__header_overhead_us(struct perf_hpp *hpp) | 84 | static int hpp__header_overhead_us(struct perf_hpp *hpp) |
| 85 | { | 85 | { |
| 86 | const char *fmt = symbol_conf.field_sep ? "%s" : "%6s"; | 86 | const char *fmt = symbol_conf.field_sep ? "%s" : "%7s"; |
| 87 | 87 | ||
| 88 | return scnprintf(hpp->buf, hpp->size, fmt, "user"); | 88 | return scnprintf(hpp->buf, hpp->size, fmt, "user"); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | static int hpp__width_overhead_us(struct perf_hpp *hpp __maybe_unused) | 91 | static int hpp__width_overhead_us(struct perf_hpp *hpp __maybe_unused) |
| 92 | { | 92 | { |
| 93 | return 6; | 93 | return 7; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | static int hpp__color_overhead_us(struct perf_hpp *hpp, struct hist_entry *he) | 96 | static int hpp__color_overhead_us(struct perf_hpp *hpp, struct hist_entry *he) |
| 97 | { | 97 | { |
| 98 | double percent = 100.0 * he->period_us / hpp->total_period; | 98 | double percent = 100.0 * he->period_us / hpp->total_period; |
| 99 | return percent_color_snprintf(hpp->buf, hpp->size, "%5.2f%%", percent); | 99 | return percent_color_snprintf(hpp->buf, hpp->size, "%6.2f%%", percent); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | static int hpp__entry_overhead_us(struct perf_hpp *hpp, struct hist_entry *he) | 102 | static int hpp__entry_overhead_us(struct perf_hpp *hpp, struct hist_entry *he) |
| 103 | { | 103 | { |
| 104 | double percent = 100.0 * he->period_us / hpp->total_period; | 104 | double percent = 100.0 * he->period_us / hpp->total_period; |
| 105 | const char *fmt = symbol_conf.field_sep ? "%.2f" : "%5.2f%%"; | 105 | const char *fmt = symbol_conf.field_sep ? "%.2f" : "%6.2f%%"; |
| 106 | 106 | ||
| 107 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 107 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
| 108 | } | 108 | } |
| @@ -121,14 +121,14 @@ static int hpp__color_overhead_guest_sys(struct perf_hpp *hpp, | |||
| 121 | struct hist_entry *he) | 121 | struct hist_entry *he) |
| 122 | { | 122 | { |
| 123 | double percent = 100.0 * he->period_guest_sys / hpp->total_period; | 123 | double percent = 100.0 * he->period_guest_sys / hpp->total_period; |
| 124 | return percent_color_snprintf(hpp->buf, hpp->size, " %5.2f%% ", percent); | 124 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%% ", percent); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | static int hpp__entry_overhead_guest_sys(struct perf_hpp *hpp, | 127 | static int hpp__entry_overhead_guest_sys(struct perf_hpp *hpp, |
| 128 | struct hist_entry *he) | 128 | struct hist_entry *he) |
| 129 | { | 129 | { |
| 130 | double percent = 100.0 * he->period_guest_sys / hpp->total_period; | 130 | double percent = 100.0 * he->period_guest_sys / hpp->total_period; |
| 131 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %5.2f%% "; | 131 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%% "; |
| 132 | 132 | ||
| 133 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 133 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
| 134 | } | 134 | } |
| @@ -147,14 +147,14 @@ static int hpp__color_overhead_guest_us(struct perf_hpp *hpp, | |||
| 147 | struct hist_entry *he) | 147 | struct hist_entry *he) |
| 148 | { | 148 | { |
| 149 | double percent = 100.0 * he->period_guest_us / hpp->total_period; | 149 | double percent = 100.0 * he->period_guest_us / hpp->total_period; |
| 150 | return percent_color_snprintf(hpp->buf, hpp->size, " %5.2f%% ", percent); | 150 | return percent_color_snprintf(hpp->buf, hpp->size, " %6.2f%% ", percent); |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | static int hpp__entry_overhead_guest_us(struct perf_hpp *hpp, | 153 | static int hpp__entry_overhead_guest_us(struct perf_hpp *hpp, |
| 154 | struct hist_entry *he) | 154 | struct hist_entry *he) |
| 155 | { | 155 | { |
| 156 | double percent = 100.0 * he->period_guest_us / hpp->total_period; | 156 | double percent = 100.0 * he->period_guest_us / hpp->total_period; |
| 157 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %5.2f%% "; | 157 | const char *fmt = symbol_conf.field_sep ? "%.2f" : " %6.2f%% "; |
| 158 | 158 | ||
| 159 | return scnprintf(hpp->buf, hpp->size, fmt, percent); | 159 | return scnprintf(hpp->buf, hpp->size, fmt, percent); |
| 160 | } | 160 | } |
