perf tools: Show progress on histogram collapsing
authorNamhyung Kim <namhyung.kim@lge.com>
Fri, 11 Oct 2013 05:15:38 +0000 (14:15 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 23 Oct 2013 18:48:24 +0000 (15:48 -0300)
It can take quite amount of time so add progress bar UI to inform user.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1381468543-25334-4-git-send-email-namhyung@kernel.org
[ perf_progress -> ui_progress ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-annotate.c
tools/perf/builtin-diff.c
tools/perf/builtin-report.c
tools/perf/builtin-top.c
tools/perf/tests/hists_link.c
tools/perf/util/hist.c
tools/perf/util/hist.h

index 17c6b494e8cc896c6d5734d91f93e2185d67f2f7..6c5ae57831f6e15ea919b91d7f88e0405a825ef3 100644 (file)
@@ -247,7 +247,7 @@ static int __cmd_annotate(struct perf_annotate *ann)
 
                if (nr_samples > 0) {
                        total_nr_samples += nr_samples;
-                       hists__collapse_resort(hists);
+                       hists__collapse_resort(hists, NULL);
                        hists__output_resort(hists);
 
                        if (symbol_conf.event_group &&
index 9c828881714cc84c7b2dc7ca4f25e775b26bbe91..b605009e803f0bf5845f96d7bca6390fdefdfc2a 100644 (file)
@@ -369,7 +369,7 @@ static void perf_evlist__collapse_resort(struct perf_evlist *evlist)
        list_for_each_entry(evsel, &evlist->entries, node) {
                struct hists *hists = &evsel->hists;
 
-               hists__collapse_resort(hists);
+               hists__collapse_resort(hists, NULL);
        }
 }
 
index e3598a456017c2d205a83a59d8efd1844ba0c3d7..98d3891392e228474e96a2ad08db6656c99d7e8e 100644 (file)
@@ -496,6 +496,7 @@ static int __cmd_report(struct perf_report *rep)
        struct map *kernel_map;
        struct kmap *kernel_kmap;
        const char *help = "For a higher level overview, try: perf report --sort comm,dso";
+       struct ui_progress prog;
        struct perf_data_file *file = session->file;
 
        signal(SIGINT, sig_handler);
@@ -557,6 +558,12 @@ static int __cmd_report(struct perf_report *rep)
                return 0;
        }
 
+       nr_samples = 0;
+       list_for_each_entry(pos, &session->evlist->entries, node)
+               nr_samples += pos->hists.nr_entries;
+
+       ui_progress__init(&prog, nr_samples, "Merging related events...");
+
        nr_samples = 0;
        list_for_each_entry(pos, &session->evlist->entries, node) {
                struct hists *hists = &pos->hists;
@@ -564,7 +571,7 @@ static int __cmd_report(struct perf_report *rep)
                if (pos->idx == 0)
                        hists->symbol_filter_str = rep->symbol_filter_str;
 
-               hists__collapse_resort(hists);
+               hists__collapse_resort(hists, &prog);
                nr_samples += hists->stats.nr_events[PERF_RECORD_SAMPLE];
 
                /* Non-group events are considered as leader */
@@ -576,6 +583,7 @@ static int __cmd_report(struct perf_report *rep)
                        hists__link(leader_hists, hists);
                }
        }
+       ui_progress__finish();
 
        if (session_done())
                return 0;
index 386d83324a8d0d519800c8b3cba7a6b5defa95f5..76c9264ed0708dee89b07691214f79542c5b8455 100644 (file)
@@ -286,7 +286,7 @@ static void perf_top__print_sym_table(struct perf_top *top)
                return;
        }
 
-       hists__collapse_resort(&top->sym_evsel->hists);
+       hists__collapse_resort(&top->sym_evsel->hists, NULL);
        hists__output_resort(&top->sym_evsel->hists);
        hists__decay_entries(&top->sym_evsel->hists,
                             top->hide_user_symbols,
@@ -552,7 +552,7 @@ static void perf_top__sort_new_samples(void *arg)
        if (t->evlist->selected != NULL)
                t->sym_evsel = t->evlist->selected;
 
-       hists__collapse_resort(&t->sym_evsel->hists);
+       hists__collapse_resort(&t->sym_evsel->hists, NULL);
        hists__output_resort(&t->sym_evsel->hists);
        hists__decay_entries(&t->sym_evsel->hists,
                             t->hide_user_symbols,
index 025503a22ff722386bbd7e9a13fe8758dee66969..b51abcb2c24347d3c6e02a8b286735b984ddd628 100644 (file)
@@ -467,7 +467,7 @@ int test__hists_link(void)
                goto out;
 
        list_for_each_entry(evsel, &evlist->entries, node) {
-               hists__collapse_resort(&evsel->hists);
+               hists__collapse_resort(&evsel->hists, NULL);
 
                if (verbose > 2)
                        print_hists(&evsel->hists);
index f0b863ef48969cc1149f404bf0f18802639215cf..7e80253074b0ef2909dec16d7b9c5d0318bb61b1 100644 (file)
@@ -399,6 +399,7 @@ static struct hist_entry *add_hist_entry(struct hists *hists,
        if (!he)
                return NULL;
 
+       hists->nr_entries++;
        rb_link_node(&he->rb_node_in, parent, p);
        rb_insert_color(&he->rb_node_in, hists->entries_in);
 out:
@@ -604,7 +605,7 @@ static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
        hists__filter_entry_by_symbol(hists, he);
 }
 
-void hists__collapse_resort(struct hists *hists)
+void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
 {
        struct rb_root *root;
        struct rb_node *next;
@@ -631,6 +632,8 @@ void hists__collapse_resort(struct hists *hists)
                         */
                        hists__apply_filters(hists, n);
                }
+               if (prog)
+                       ui_progress__update(prog, 1);
        }
 }
 
index 20b175808cd372c031f3e2cf2cc3ad0d49d8df70..0c7ce8bb8ebab0b71869cd5362727dd85aac0fef 100644 (file)
@@ -5,6 +5,7 @@
 #include <pthread.h>
 #include "callchain.h"
 #include "header.h"
+#include "ui/progress.h"
 
 extern struct callchain_param callchain_param;
 
@@ -108,7 +109,7 @@ struct hist_entry *__hists__add_mem_entry(struct hists *self,
                                          u64 weight);
 
 void hists__output_resort(struct hists *self);
-void hists__collapse_resort(struct hists *self);
+void hists__collapse_resort(struct hists *self, struct ui_progress *prog);
 
 void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel);
 void hists__output_recalc_col_len(struct hists *hists, int max_rows);