summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/newt.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-05-11 11:10:15 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-05-11 12:43:10 -0300
commitb09e0190acf88c7fe3b05e3c331e1b2ef5310896 (patch)
tree260c82190298a9ee1b298679c6457c6b1735541a /tools/perf/util/newt.c
parente3174cfd2a1e28fff774681f00a0eef3d31da970 (diff)
downloadlinux-stable-b09e0190acf88c7fe3b05e3c331e1b2ef5310896.tar.gz
linux-stable-b09e0190acf88c7fe3b05e3c331e1b2ef5310896.tar.bz2
linux-stable-b09e0190acf88c7fe3b05e3c331e1b2ef5310896.zip
perf hist: Adopt filter by dso and by thread methods from the newt browser
Those are really not specific to the newt code, can be used by other UI frontends. Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/newt.c')
-rw-r--r--tools/perf/util/newt.c80
1 files changed, 14 insertions, 66 deletions
diff --git a/tools/perf/util/newt.c b/tools/perf/util/newt.c
index e283a6e6b6e0..638b519e72b8 100644
--- a/tools/perf/util/newt.c
+++ b/tools/perf/util/newt.c
@@ -410,8 +410,8 @@ static void hist_browser__delete(struct hist_browser *self)
free(self);
}
-static int hist_browser__populate(struct hist_browser *self, struct rb_root *hists,
- u64 nr_hists, u64 session_total, const char *title)
+static int hist_browser__populate(struct hist_browser *self, struct hists *hists,
+ const char *title)
{
int max_len = 0, idx, cols, rows;
struct ui_progress *progress;
@@ -426,7 +426,7 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his
}
snprintf(str, sizeof(str), "Samples: %Ld ",
- session_total);
+ hists->stats.total);
newtDrawRootText(0, 0, str);
newtGetScreenSize(NULL, &rows);
@@ -442,24 +442,25 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his
newtComponentAddCallback(self->tree, hist_browser__selection,
&self->selection);
- progress = ui_progress__new("Adding entries to the browser...", nr_hists);
+ progress = ui_progress__new("Adding entries to the browser...",
+ hists->nr_entries);
if (progress == NULL)
return -1;
idx = 0;
- for (nd = rb_first(hists); nd; nd = rb_next(nd)) {
+ for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
int len;
if (h->filtered)
continue;
- len = hist_entry__append_browser(h, self->tree, session_total);
+ len = hist_entry__append_browser(h, self->tree, hists->stats.total);
if (len > max_len)
max_len = len;
if (symbol_conf.use_callchain)
hist_entry__append_callchain_browser(h, self->tree,
- session_total, idx++);
+ hists->stats.total, idx++);
++curr_hist;
if (curr_hist % 5)
ui_progress__update(progress, curr_hist);
@@ -490,57 +491,6 @@ static int hist_browser__populate(struct hist_browser *self, struct rb_root *his
return 0;
}
-enum hist_filter {
- HIST_FILTER__DSO,
- HIST_FILTER__THREAD,
-};
-
-static u64 hists__filter_by_dso(struct rb_root *hists, const struct dso *dso,
- u64 *session_total)
-{
- struct rb_node *nd;
- u64 nr_hists = 0;
-
- *session_total = 0;
-
- for (nd = rb_first(hists); nd; nd = rb_next(nd)) {
- struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
-
- if (dso != NULL && (h->ms.map == NULL || h->ms.map->dso != dso)) {
- h->filtered |= (1 << HIST_FILTER__DSO);
- continue;
- }
- h->filtered &= ~(1 << HIST_FILTER__DSO);
- ++nr_hists;
- *session_total += h->count;
- }
-
- return nr_hists;
-}
-
-static u64 hists__filter_by_thread(struct rb_root *hists, const struct thread *thread,
- u64 *session_total)
-{
- struct rb_node *nd;
- u64 nr_hists = 0;
-
- *session_total = 0;
-
- for (nd = rb_first(hists); nd; nd = rb_next(nd)) {
- struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
-
- if (thread != NULL && h->thread != thread) {
- h->filtered |= (1 << HIST_FILTER__THREAD);
- continue;
- }
- h->filtered &= ~(1 << HIST_FILTER__THREAD);
- ++nr_hists;
- *session_total += h->count;
- }
-
- return nr_hists;
-}
-
static struct thread *hist_browser__selected_thread(struct hist_browser *self)
{
int *indexes;
@@ -577,9 +527,7 @@ static int hist_browser__title(char *bf, size_t size, const char *input_name,
return printed ?: snprintf(bf, size, "Report: %s", input_name);
}
-int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
- u64 session_total, const char *helpline,
- const char *input_name)
+int hists__browse(struct hists *self, const char *helpline, const char *input_name)
{
struct hist_browser *browser = hist_browser__new();
const struct thread *thread_filter = NULL;
@@ -595,7 +543,7 @@ int perf_session__browse_hists(struct rb_root *hists, u64 nr_hists,
hist_browser__title(msg, sizeof(msg), input_name,
dso_filter, thread_filter);
- if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0)
+ if (hist_browser__populate(browser, self, msg) < 0)
goto out;
while (1) {
@@ -672,10 +620,10 @@ do_annotate:
newtPushHelpLine(msg);
dso_filter = dso;
}
- nr_hists = hists__filter_by_dso(hists, dso_filter, &session_total);
+ hists__filter_by_dso(self, dso_filter);
hist_browser__title(msg, sizeof(msg), input_name,
dso_filter, thread_filter);
- if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0)
+ if (hist_browser__populate(browser, self, msg) < 0)
goto out;
} else if (choice == zoom_thread) {
if (thread_filter) {
@@ -689,10 +637,10 @@ do_annotate:
newtPushHelpLine(msg);
thread_filter = thread;
}
- nr_hists = hists__filter_by_thread(hists, thread_filter, &session_total);
+ hists__filter_by_thread(self, thread_filter);
hist_browser__title(msg, sizeof(msg), input_name,
dso_filter, thread_filter);
- if (hist_browser__populate(browser, hists, nr_hists, session_total, msg) < 0)
+ if (hist_browser__populate(browser, self, msg) < 0)
goto out;
}
}