Skip to content

Commit

Permalink
perf hist: Introduce routine to measure lenght of formatted entry
Browse files Browse the repository at this point in the history
Will be used to figure out the window width needed in the new tree
widget.

Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jul 27, 2010
1 parent b61b55e commit 06daaab
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tools/perf/util/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,33 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
return ret;
}

/*
* See hists__fprintf to match the column widths
*/
unsigned int hists__sort_list_width(struct hists *self)
{
struct sort_entry *se;
int ret = 9; /* total % */

if (symbol_conf.show_cpu_utilization) {
ret += 7; /* count_sys % */
ret += 6; /* count_us % */
if (perf_guest) {
ret += 13; /* count_guest_sys % */
ret += 12; /* count_guest_us % */
}
}

if (symbol_conf.show_nr_samples)
ret += 11;

list_for_each_entry(se, &hist_entry__sort_list, list)
if (!se->elide)
ret += 2 + hists__col_len(self, se->se_width_idx);

return ret;
}

static void hists__remove_entry_filter(struct hists *self, struct hist_entry *h,
enum hist_filter filter)
{
Expand Down
3 changes: 3 additions & 0 deletions tools/perf/util/hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,7 @@ int hist_entry__tui_annotate(struct hist_entry *self);

int hists__tui_browse_tree(struct rb_root *self, const char *help);
#endif

unsigned int hists__sort_list_width(struct hists *self);

#endif /* __PERF_HIST_H */

0 comments on commit 06daaab

Please sign in to comment.