Re: [PATCH 16/23] perf hists browser: Count number of hierarchy entries

2016-02-10 Thread Namhyung Kim
On Wed, Feb 10, 2016 at 01:52:08PM +0100, Jiri Olsa wrote:
> On Fri, Feb 05, 2016 at 10:01:48PM +0900, Namhyung Kim wrote:
> 
> SNIP
> 
> > +static int hierarchy_count_rows(struct hist_browser *hb, struct hist_entry 
> > *he,
> > +   bool include_children)
> > +{
> > +   int count = 0;
> > +   struct rb_node *node;
> > +   struct hist_entry *child;
> > +
> > +   if (he->leaf)
> > +   return callchain__count_rows(>sorted_chain);
> > +
> > +   node = rb_first(>hroot_out);
> > +   while (node) {
> > +   float percent;
> > +
> > +   child = rb_entry(node, struct hist_entry, rb_node);
> > +   percent = hist_entry__get_percent_limit(child);
> > +
> > +   if (!child->filtered && percent >= hb->min_pcnt) {
> > +   count++;
> > +
> > +   if (include_children && child->unfolded)
> > +   count += hierarchy_count_rows(hb, child, true);
> > +   }
> > +
> > +   node = rb_next(node);
> > +   }
> > +   return count;
> > +}
> 
> SNIP
> 
> > +   if (he->leaf)
> > +   browser->nr_callchain_rows -= he->nr_rows;
> > else
> > +   browser->nr_hierarchy_entries -= he->nr_rows;
> > +
> > +   if (symbol_conf.report_hierarchy)
> > +   child_rows = hierarchy_count_rows(browser, he, true);
> > +
> > +   if (he->unfolded) {
> > +   if (he->leaf)
> > +   he->nr_rows = 
> > callchain__count_rows(>sorted_chain);
> > +   else
> > +   he->nr_rows = hierarchy_count_rows(browser, he, 
> > false);
> 
> looks like above condition could go to just following call:
> 
>   he->nr_rows = hierarchy_count_rows(browser, he, false);
> 
> because there's same condtiion in the hierarchy_count_rows function

That's true.  But I wrote it that way since it's aligned with other
part of the code.

Thanks,
Namhyung


Re: [PATCH 16/23] perf hists browser: Count number of hierarchy entries

2016-02-10 Thread Jiri Olsa
On Fri, Feb 05, 2016 at 10:01:48PM +0900, Namhyung Kim wrote:

SNIP

> +static int hierarchy_count_rows(struct hist_browser *hb, struct hist_entry 
> *he,
> + bool include_children)
> +{
> + int count = 0;
> + struct rb_node *node;
> + struct hist_entry *child;
> +
> + if (he->leaf)
> + return callchain__count_rows(>sorted_chain);
> +
> + node = rb_first(>hroot_out);
> + while (node) {
> + float percent;
> +
> + child = rb_entry(node, struct hist_entry, rb_node);
> + percent = hist_entry__get_percent_limit(child);
> +
> + if (!child->filtered && percent >= hb->min_pcnt) {
> + count++;
> +
> + if (include_children && child->unfolded)
> + count += hierarchy_count_rows(hb, child, true);
> + }
> +
> + node = rb_next(node);
> + }
> + return count;
> +}

SNIP

> + if (he->leaf)
> + browser->nr_callchain_rows -= he->nr_rows;
>   else
> + browser->nr_hierarchy_entries -= he->nr_rows;
> +
> + if (symbol_conf.report_hierarchy)
> + child_rows = hierarchy_count_rows(browser, he, true);
> +
> + if (he->unfolded) {
> + if (he->leaf)
> + he->nr_rows = 
> callchain__count_rows(>sorted_chain);
> + else
> + he->nr_rows = hierarchy_count_rows(browser, he, 
> false);

looks like above condition could go to just following call:

he->nr_rows = hierarchy_count_rows(browser, he, false);

because there's same condtiion in the hierarchy_count_rows function

thanks,
jirka


Re: [PATCH 16/23] perf hists browser: Count number of hierarchy entries

2016-02-10 Thread Namhyung Kim
On Wed, Feb 10, 2016 at 01:52:08PM +0100, Jiri Olsa wrote:
> On Fri, Feb 05, 2016 at 10:01:48PM +0900, Namhyung Kim wrote:
> 
> SNIP
> 
> > +static int hierarchy_count_rows(struct hist_browser *hb, struct hist_entry 
> > *he,
> > +   bool include_children)
> > +{
> > +   int count = 0;
> > +   struct rb_node *node;
> > +   struct hist_entry *child;
> > +
> > +   if (he->leaf)
> > +   return callchain__count_rows(>sorted_chain);
> > +
> > +   node = rb_first(>hroot_out);
> > +   while (node) {
> > +   float percent;
> > +
> > +   child = rb_entry(node, struct hist_entry, rb_node);
> > +   percent = hist_entry__get_percent_limit(child);
> > +
> > +   if (!child->filtered && percent >= hb->min_pcnt) {
> > +   count++;
> > +
> > +   if (include_children && child->unfolded)
> > +   count += hierarchy_count_rows(hb, child, true);
> > +   }
> > +
> > +   node = rb_next(node);
> > +   }
> > +   return count;
> > +}
> 
> SNIP
> 
> > +   if (he->leaf)
> > +   browser->nr_callchain_rows -= he->nr_rows;
> > else
> > +   browser->nr_hierarchy_entries -= he->nr_rows;
> > +
> > +   if (symbol_conf.report_hierarchy)
> > +   child_rows = hierarchy_count_rows(browser, he, true);
> > +
> > +   if (he->unfolded) {
> > +   if (he->leaf)
> > +   he->nr_rows = 
> > callchain__count_rows(>sorted_chain);
> > +   else
> > +   he->nr_rows = hierarchy_count_rows(browser, he, 
> > false);
> 
> looks like above condition could go to just following call:
> 
>   he->nr_rows = hierarchy_count_rows(browser, he, false);
> 
> because there's same condtiion in the hierarchy_count_rows function

That's true.  But I wrote it that way since it's aligned with other
part of the code.

Thanks,
Namhyung


Re: [PATCH 16/23] perf hists browser: Count number of hierarchy entries

2016-02-10 Thread Jiri Olsa
On Fri, Feb 05, 2016 at 10:01:48PM +0900, Namhyung Kim wrote:

SNIP

> +static int hierarchy_count_rows(struct hist_browser *hb, struct hist_entry 
> *he,
> + bool include_children)
> +{
> + int count = 0;
> + struct rb_node *node;
> + struct hist_entry *child;
> +
> + if (he->leaf)
> + return callchain__count_rows(>sorted_chain);
> +
> + node = rb_first(>hroot_out);
> + while (node) {
> + float percent;
> +
> + child = rb_entry(node, struct hist_entry, rb_node);
> + percent = hist_entry__get_percent_limit(child);
> +
> + if (!child->filtered && percent >= hb->min_pcnt) {
> + count++;
> +
> + if (include_children && child->unfolded)
> + count += hierarchy_count_rows(hb, child, true);
> + }
> +
> + node = rb_next(node);
> + }
> + return count;
> +}

SNIP

> + if (he->leaf)
> + browser->nr_callchain_rows -= he->nr_rows;
>   else
> + browser->nr_hierarchy_entries -= he->nr_rows;
> +
> + if (symbol_conf.report_hierarchy)
> + child_rows = hierarchy_count_rows(browser, he, true);
> +
> + if (he->unfolded) {
> + if (he->leaf)
> + he->nr_rows = 
> callchain__count_rows(>sorted_chain);
> + else
> + he->nr_rows = hierarchy_count_rows(browser, he, 
> false);

looks like above condition could go to just following call:

he->nr_rows = hierarchy_count_rows(browser, he, false);

because there's same condtiion in the hierarchy_count_rows function

thanks,
jirka