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>
This commit is contained in:
@@ -707,12 +707,11 @@ void hists__output_recalc_col_len(struct hists *hists, int max_rows)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
|
static int hist_entry__pcnt_snprintf(struct hist_entry *self, char *s,
|
||||||
struct hists *hists, struct hists *pair_hists,
|
size_t size, struct hists *pair_hists,
|
||||||
bool show_displacement, long displacement,
|
bool show_displacement, long displacement,
|
||||||
bool color, u64 session_total)
|
bool color, u64 session_total)
|
||||||
{
|
{
|
||||||
struct sort_entry *se;
|
|
||||||
u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us;
|
u64 period, total, period_sys, period_us, period_guest_sys, period_guest_us;
|
||||||
u64 nr_events;
|
u64 nr_events;
|
||||||
const char *sep = symbol_conf.field_sep;
|
const char *sep = symbol_conf.field_sep;
|
||||||
@@ -818,12 +817,22 @@ int hist_entry__snprintf(struct hist_entry *self, char *s, size_t size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hist_entry__snprintf(struct hist_entry *he, char *s, size_t size,
|
||||||
|
struct hists *hists)
|
||||||
|
{
|
||||||
|
const char *sep = symbol_conf.field_sep;
|
||||||
|
struct sort_entry *se;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
list_for_each_entry(se, &hist_entry__sort_list, list) {
|
list_for_each_entry(se, &hist_entry__sort_list, list) {
|
||||||
if (se->elide)
|
if (se->elide)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret += snprintf(s + ret, size - ret, "%s", sep ?: " ");
|
ret += snprintf(s + ret, size - ret, "%s", sep ?: " ");
|
||||||
ret += se->se_snprintf(self, s + ret, size - ret,
|
ret += se->se_snprintf(he, s + ret, size - ret,
|
||||||
hists__col_len(hists, se->se_width_idx));
|
hists__col_len(hists, se->se_width_idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -835,13 +844,15 @@ int hist_entry__fprintf(struct hist_entry *he, size_t size, struct hists *hists,
|
|||||||
long displacement, FILE *fp, u64 session_total)
|
long displacement, FILE *fp, u64 session_total)
|
||||||
{
|
{
|
||||||
char bf[512];
|
char bf[512];
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (size == 0 || size > sizeof(bf))
|
if (size == 0 || size > sizeof(bf))
|
||||||
size = sizeof(bf);
|
size = sizeof(bf);
|
||||||
|
|
||||||
hist_entry__snprintf(he, bf, size, hists, pair_hists,
|
ret = hist_entry__pcnt_snprintf(he, bf, size, pair_hists,
|
||||||
show_displacement, displacement,
|
show_displacement, displacement,
|
||||||
true, session_total);
|
true, session_total);
|
||||||
|
hist_entry__snprintf(he, bf + ret, size - ret, hists);
|
||||||
return fprintf(fp, "%s\n", bf);
|
return fprintf(fp, "%s\n", bf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,9 +68,7 @@ int hist_entry__fprintf(struct hist_entry *he, size_t size, struct hists *hists,
|
|||||||
struct hists *pair_hists, bool show_displacement,
|
struct hists *pair_hists, bool show_displacement,
|
||||||
long displacement, FILE *fp, u64 session_total);
|
long displacement, FILE *fp, u64 session_total);
|
||||||
int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size,
|
int hist_entry__snprintf(struct hist_entry *self, char *bf, size_t size,
|
||||||
struct hists *hists, struct hists *pair_hists,
|
struct hists *hists);
|
||||||
bool show_displacement, long displacement,
|
|
||||||
bool color, u64 total);
|
|
||||||
void hist_entry__free(struct hist_entry *);
|
void hist_entry__free(struct hist_entry *);
|
||||||
|
|
||||||
void hists__output_resort(struct hists *self);
|
void hists__output_resort(struct hists *self);
|
||||||
|
@@ -547,7 +547,7 @@ static int hist_browser__show_entry(struct hist_browser *self,
|
|||||||
char s[256];
|
char s[256];
|
||||||
double percent;
|
double percent;
|
||||||
int printed = 0;
|
int printed = 0;
|
||||||
int width = self->b.width;
|
int width = self->b.width - 6; /* The percentage */
|
||||||
char folded_sign = ' ';
|
char folded_sign = ' ';
|
||||||
bool current_entry = ui_browser__is_current_entry(&self->b, row);
|
bool current_entry = ui_browser__is_current_entry(&self->b, row);
|
||||||
off_t row_offset = entry->row_offset;
|
off_t row_offset = entry->row_offset;
|
||||||
@@ -563,8 +563,7 @@ static int hist_browser__show_entry(struct hist_browser *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (row_offset == 0) {
|
if (row_offset == 0) {
|
||||||
hist_entry__snprintf(entry, s, sizeof(s), self->hists, NULL, false,
|
hist_entry__snprintf(entry, s, sizeof(s), self->hists);
|
||||||
0, false, self->hists->stats.total_period);
|
|
||||||
percent = (entry->period * 100.0) / self->hists->stats.total_period;
|
percent = (entry->period * 100.0) / self->hists->stats.total_period;
|
||||||
|
|
||||||
ui_browser__set_percent_color(&self->b, percent, current_entry);
|
ui_browser__set_percent_color(&self->b, percent, current_entry);
|
||||||
@@ -574,6 +573,8 @@ static int hist_browser__show_entry(struct hist_browser *self,
|
|||||||
width -= 2;
|
width -= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slsmg_printf(" %5.2f%%", percent);
|
||||||
|
|
||||||
/* The scroll bar isn't being used */
|
/* The scroll bar isn't being used */
|
||||||
if (!self->b.navkeypressed)
|
if (!self->b.navkeypressed)
|
||||||
width += 1;
|
width += 1;
|
||||||
|
Reference in New Issue
Block a user