perf ui/tui: Show column header in hist browser
Namhyung Kim
maintainerAdd a line for showing column headers like --stdio.
--- tools/perf/ui/browser.c | 4 +-- tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-)
tools/perf/ui/browser.c +2 -2
@@ -278,8 +278,8 @@ void ui_browser__hide(struct ui_browser *browser)static void ui_browser__scrollbar_set (struct ui_browser *browser) {int height = browser->height, h =0 , pct =0 , - col = browser->width, - row = browser->y -1 ; + col = browser->width, row =0 ; +if (browser->nr_entries >1 ) { pct = ((browser->index * (browser->height - 1)) /
tools/perf/ui/browsers/hists.c +55 -0
79 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Quoted 1 line · Namhyung Kim
Add a line for showing column headers like --stdio.
;-) I'll check your change
jirka
Quoted 112 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/ui/browser.c | 4 +-- tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-)tools/perf/ui/browser.c +2
-2@@ -278,8 +278,8 @@ void ui_browser__hide(struct ui_browser *browser)static void ui_browser__scrollbar_set (struct ui_browser *browser) {int height = browser->height, h =0 , pct =0 , - col = browser->width, - row = browser->y -1 ; + col = browser->width, row =0 ; +if (browser->nr_entries >1 ) { pct = ((browser->index * (browser->height - 1)) /tools/perf/ui/browsers/hists.c +55
-0@@ -25,6 +25,7 @@ struct hist_browser {struct map_symbol *selection;int print_seq;bool show_dso; +bool show_column_header;float min_pcnt;u64 nr_pcnt_entries; };@@ -312,6 +313,57 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser)static void hist_browser__update_pcnt_entries (struct hist_browser *hb); +static void hist_browser__column_header (struct hist_browser *browser) +{ +struct perf_hpp_fmt *fmt; +struct sort_entry *se; +struct hists *hists = browser->hists; +bool show = browser->show_column_header; +unsigned int width; + +pthread_mutex_lock (&ui__lock); + +if (!show) + goto out; + +ui_browser__gotorc (&browser->b,0 ,0 ); + +perf_hpp__for_each_format (fmt) { +char buf[128 ]; +struct perf_hpp hpp = { + .buf = buf, + .size =sizeof (buf), + .ptr =hists_to_evsel (hists), + }; + + width = fmt->width (fmt, &hpp); + fmt->header (fmt, &hpp); + +slsmg_printf (" %-*s" , width, hpp.buf); + } + +list_for_each_entry (se, &hist_entry__sort_list, list) { +if (se->elide) +continue ; + + width =strlen (se->se_header); +if (!hists__new_col_len (hists, se->se_width_idx, width)) + width =hists__col_len (hists, se->se_width_idx); + +slsmg_printf (" %-*s" , width, se->se_header); + } + +/* +* We just called ui_browser__refresh_dimensions(). +* Update it to honor a new column header line. +*/ + browser->b.y++; + browser->b.height--; + +out: +pthread_mutex_unlock (&ui__lock); +} +static int hist_browser__run (struct hist_browser *browser,const char *ev_name,struct hist_browser_timer *hbt) {@@ -331,6 +383,8 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name, "Press '?' for help on key bindings") < 0)return -1 ; +hist_browser__column_header (browser); +while (1 ) { key =ui_browser__run (&browser->b, delay_secs);@@ -1198,6 +1252,7 @@ static struct hist_browser *hist_browser__new(struct hists *hists) browser->b.refresh = hist_browser__refresh; browser->b.seek = ui_browser__hists_seek; browser->b.use_navkeypressed = true; + browser->show_column_header = true; }return browser;Signature · 1 line
1.7.11.7
Em Wed, Jan 15, 2014 at 01:10:44PM +0100, Jiri Olsa escreveu:
Quoted 8 lines · Namhyung Kim
Quoted 1 line
Add a line for showing column headers like --stdio.
;-) I'll check your change
From a quick view, your change looks better, i.e. being able to toggle
the header line.
Please let me know what you guys end up agreeing is best.
- Arnaldo
Quoted 114 lines
jirka
Quoted 112 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/ui/browser.c | 4 +-- tools/perf/ui/browsers/hists.c | 55 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-)tools/perf/ui/browser.c +2
-2@@ -278,8 +278,8 @@ void ui_browser__hide(struct ui_browser *browser)static void ui_browser__scrollbar_set (struct ui_browser *browser) {int height = browser->height, h =0 , pct =0 , - col = browser->width, - row = browser->y -1 ; + col = browser->width, row =0 ; +if (browser->nr_entries >1 ) { pct = ((browser->index * (browser->height - 1)) /tools/perf/ui/browsers/hists.c +55
-0@@ -25,6 +25,7 @@ struct hist_browser {struct map_symbol *selection;int print_seq;bool show_dso; +bool show_column_header;float min_pcnt;u64 nr_pcnt_entries; };@@ -312,6 +313,57 @@ static void ui_browser__warn_lost_events(struct ui_browser *browser)static void hist_browser__update_pcnt_entries (struct hist_browser *hb); +static void hist_browser__column_header (struct hist_browser *browser) +{ +struct perf_hpp_fmt *fmt; +struct sort_entry *se; +struct hists *hists = browser->hists; +bool show = browser->show_column_header; +unsigned int width; + +pthread_mutex_lock (&ui__lock); + +if (!show) + goto out; + +ui_browser__gotorc (&browser->b,0 ,0 ); + +perf_hpp__for_each_format (fmt) { +char buf[128 ]; +struct perf_hpp hpp = { + .buf = buf, + .size =sizeof (buf), + .ptr =hists_to_evsel (hists), + }; + + width = fmt->width (fmt, &hpp); + fmt->header (fmt, &hpp); + +slsmg_printf (" %-*s" , width, hpp.buf); + } + +list_for_each_entry (se, &hist_entry__sort_list, list) { +if (se->elide) +continue ; + + width =strlen (se->se_header); +if (!hists__new_col_len (hists, se->se_width_idx, width)) + width =hists__col_len (hists, se->se_width_idx); + +slsmg_printf (" %-*s" , width, se->se_header); + } + +/* +* We just called ui_browser__refresh_dimensions(). +* Update it to honor a new column header line. +*/ + browser->b.y++; + browser->b.height--; + +out: +pthread_mutex_unlock (&ui__lock); +} +static int hist_browser__run (struct hist_browser *browser,const char *ev_name,struct hist_browser_timer *hbt) {@@ -331,6 +383,8 @@ static int hist_browser__run(struct hist_browser *browser, const char *ev_name, "Press '?' for help on key bindings") < 0)return -1 ; +hist_browser__column_header (browser); +while (1 ) { key =ui_browser__run (&browser->b, delay_secs);@@ -1198,6 +1252,7 @@ static struct hist_browser *hist_browser__new(struct hists *hists) browser->b.refresh = hist_browser__refresh; browser->b.seek = ui_browser__hists_seek; browser->b.use_navkeypressed = true; + browser->show_column_header = true; }return browser;Signature · 1 line
1.7.11.7
Namhyung Kim
maintainerHi Arnaldo and Jiri,
Quoted 4 lines · Arnaldo Carvalho de Melo
Em Wed, Jan 15, 2014 at 01:10:44PM +0100, Jiri Olsa escreveu:
Quoted 3 lines · Namhyung Kim
Quoted 1 line
Add a line for showing column headers like --stdio.
Quoted 8 lines
Quoted 3 lines
;-) I'll check your change
From a quick view, your change looks better, i.e. being able to toggle the header line.
Please let me know what you guys end up agreeing is best.
Yes, looking at the source, Jiri's version looks much better. I was lazy for sorting column width and supporting a hotkey for toggling. :) I just wanted to see how you guys think, so the rfc.
Thanks,
Namhyung
Quoted 11 lines · Namhyung Kim
Hi Arnaldo and Jiri,
Quoted 8 lines · Arnaldo Carvalho de Melo
Em Wed, Jan 15, 2014 at 01:10:44PM +0100, Jiri Olsa escreveu:
Quoted 6 lines · Namhyung Kim
Quoted 1 line
Add a line for showing column headers like --stdio.
;-) I'll check your change
Quoted 8 lines
Quoted 4 lines
From a quick view, your change looks better, i.e. being able to toggle the header line.
Please let me know what you guys end up agreeing is best.
Yes, looking at the source, Jiri's version looks much better. I was lazy for sorting column width and supporting a hotkey for toggling. :) I just wanted to see how you guys think, so the rfc.
ok, I'll send it out soon with my other changes
thanks,
jirka