File perf-annotate-tui-clarify-calculation-of-column-header-widths.patch of Package perf
103
1
From: Arnaldo Carvalho de Melo <acme@redhat.com>
2
Date: Thu, 27 Jul 2017 12:05:58 -0300
3
Subject: perf annotate TUI: Clarify calculation of column header widths
4
Git-commit: bc1e5d60cebb711ca3783a87a969d18db376d357
5
Patch-mainline: v4.14-rc1
6
References: bsc#1070010 (git-fixes - dependency)
7
Signed-off-By: Tony Jones <tonyj@suse.de>
8
9
In commit f8f4aaead579 ("perf annotate: Finally display IPC and cycle
10
accounting") the 'pcnt_width' variable was abused in a few places to
11
also include the optional width of the "IPC" and "cycles" columns, while
12
in other places we stopped using 'pcnt_width' and instead its previous
13
equation...
14
15
Now that we need to tap into annotate_browser__pcnt_width() to consider
16
if --show-total-period is being used and instead of that hardcoded 7
17
(strlen("Percent")) we need to use it or strlen("Event count") we need
18
this properly clarified to avoid having to touch all the (7 * nr_events)
19
places.
20
21
Clarify this by introducing a separate annotate_browser__cycles_width()
22
to leave the pcnt_width calculate just what its name implies.
23
24
Cc: Taeung Song <treeze.taeung@gmail.com>
25
Cc: Milian Wolff <milian.wolff@kdab.com>
26
Cc: Namhyung Kim <namhyung@kernel.org>
27
Cc: Jiri Olsa <jolsa@redhat.com>
28
Cc: Andi Kleen <ak@linux.intel.com>
29
Link: http://lkml.kernel.org/n/tip-szgb07t4k5wtvks8nzwkg710@git.kernel.org
30
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
31
---
32
tools/perf/ui/browsers/annotate.c | 20 +++++++++++---------
33
1 file changed, 11 insertions(+), 9 deletions(-)
34
35
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
36
index c382b1d8af42..0f4bcc0d140c 100644
37
--- a/tools/perf/ui/browsers/annotate.c
38
+++ b/tools/perf/ui/browsers/annotate.c
39
40
41
static int annotate_browser__pcnt_width(struct annotate_browser *ab)
42
{
43
- int w = 7 * ab->nr_events;
44
+ return 7 * ab->nr_events;
45
+}
46
47
- if (ab->have_cycles)
48
- w += IPC_WIDTH + CYCLES_WIDTH;
49
- return w;
50
+static int annotate_browser__cycles_width(struct annotate_browser *ab)
51
+{
52
+ return ab->have_cycles ? IPC_WIDTH + CYCLES_WIDTH : 0;
53
}
54
55
static void annotate_browser__write(struct ui_browser *browser, void *entry, int row)
56
57
(!current_entry || (browser->use_navkeypressed &&
58
!browser->navkeypressed)));
59
int width = browser->width, printed;
60
- int i, pcnt_width = annotate_browser__pcnt_width(ab);
61
+ int i, pcnt_width = annotate_browser__pcnt_width(ab),
62
+ cycles_width = annotate_browser__cycles_width(ab);
63
double percent_max = 0.0;
64
char bf[256];
65
bool show_title = false;
66
67
ui_browser__set_percent_color(browser, 0, current_entry);
68
69
if (!show_title)
70
- ui_browser__write_nstring(browser, " ", 7 * ab->nr_events);
71
+ ui_browser__write_nstring(browser, " ", pcnt_width);
72
else
73
ui_browser__printf(browser, "%*s", 7, "Percent");
74
}
75
76
width += 1;
77
78
if (!*dl->line)
79
- ui_browser__write_nstring(browser, " ", width - pcnt_width);
80
+ ui_browser__write_nstring(browser, " ", width - pcnt_width - cycles_width);
81
else if (dl->offset == -1) {
82
if (dl->line_nr && annotate_browser__opts.show_linenr)
83
printed = scnprintf(bf, sizeof(bf), "%-*d ",
84
85
printed = scnprintf(bf, sizeof(bf), "%*s ",
86
ab->addr_width, " ");
87
ui_browser__write_nstring(browser, bf, printed);
88
- ui_browser__write_nstring(browser, dl->line, width - printed - pcnt_width + 1);
89
+ ui_browser__write_nstring(browser, dl->line, width - printed - pcnt_width - cycles_width + 1);
90
} else {
91
u64 addr = dl->offset;
92
int color = -1;
93
94
}
95
96
disasm_line__scnprintf(dl, bf, sizeof(bf), !annotate_browser__opts.use_offset);
97
- ui_browser__write_nstring(browser, bf, width - pcnt_width - 3 - printed);
98
+ ui_browser__write_nstring(browser, bf, width - pcnt_width - cycles_width - 3 - printed);
99
}
100
101
if (current_entry)
102
103