next = rb_first(&session->hists_tree);
while (next) {
struct hists *hists;
- u64 nr_hists;
hists = rb_entry(next, struct hists, rb_node);
hists__collapse_resort(hists);
- nr_hists = hists__output_resort(hists);
+ hists__output_resort(hists);
if (use_browser)
- perf_session__browse_hists(&hists->entries, nr_hists,
+ perf_session__browse_hists(&hists->entries,
+ hists->nr_entries,
hists->stats.total, help,
input_name);
else {
return self;
}
+static void hists__inc_nr_entries(struct hists *self, struct hist_entry *entry)
+{
+ if (entry->ms.sym && self->max_sym_namelen < entry->ms.sym->namelen)
+ self->max_sym_namelen = entry->ms.sym->namelen;
+ ++self->nr_entries;
+}
+
struct hist_entry *__hists__add_entry(struct hists *self,
struct addr_location *al,
struct symbol *sym_parent, u64 count)
return NULL;
rb_link_node(&he->rb_node, parent, p);
rb_insert_color(&he->rb_node, &self->entries);
+ hists__inc_nr_entries(self, he);
out:
hist_entry__add_cpumode_count(he, al->cpumode, count);
return he;
* collapse the histogram
*/
-static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
+static bool collapse__insert_entry(struct rb_root *root, struct hist_entry *he)
{
struct rb_node **p = &root->rb_node;
struct rb_node *parent = NULL;
if (!cmp) {
iter->count += he->count;
hist_entry__free(he);
- return;
+ return false;
}
if (cmp < 0)
rb_link_node(&he->rb_node, parent, p);
rb_insert_color(&he->rb_node, root);
+ return true;
}
void hists__collapse_resort(struct hists *self)
tmp = RB_ROOT;
next = rb_first(&self->entries);
+ self->nr_entries = 0;
+ self->max_sym_namelen = 0;
while (next) {
n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node);
rb_erase(&n->rb_node, &self->entries);
- collapse__insert_entry(&tmp, n);
+ if (collapse__insert_entry(&tmp, n))
+ hists__inc_nr_entries(self, n);
}
self->entries = tmp;
rb_insert_color(&he->rb_node, entries);
}
-u64 hists__output_resort(struct hists *self)
+void hists__output_resort(struct hists *self)
{
struct rb_root tmp;
struct rb_node *next;
struct hist_entry *n;
u64 min_callchain_hits;
- u64 nr_hists = 0;
min_callchain_hits = self->stats.total * (callchain_param.min_percent / 100);
tmp = RB_ROOT;
next = rb_first(&self->entries);
+ self->nr_entries = 0;
+ self->max_sym_namelen = 0;
+
while (next) {
n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node);
rb_erase(&n->rb_node, &self->entries);
__hists__insert_output_entry(&tmp, n, min_callchain_hits);
- ++nr_hists;
+ hists__inc_nr_entries(self, n);
}
self->entries = tmp;
- return nr_hists;
}
static size_t callchain__fprintf_left_margin(FILE *fp, int left_margin)
struct hists {
struct rb_node rb_node;
struct rb_root entries;
+ u64 nr_entries;
struct events_stats stats;
u64 config;
u64 event_stream;
u32 type;
+ u32 max_sym_namelen;
};
struct hist_entry *__hists__add_entry(struct hists *self,
long displacement, bool color, u64 total);
void hist_entry__free(struct hist_entry *);
-u64 hists__output_resort(struct hists *self);
+void hists__output_resort(struct hists *self);
void hists__collapse_resort(struct hists *self);
size_t hists__fprintf(struct hists *self, struct hists *pair,
bool show_displacement, FILE *fp);