diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-11 10:10:15 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-05-11 11:43:10 -0400 |
commit | b09e0190acf88c7fe3b05e3c331e1b2ef5310896 (patch) | |
tree | 260c82190298a9ee1b298679c6457c6b1735541a /tools/perf/util/hist.c | |
parent | e3174cfd2a1e28fff774681f00a0eef3d31da970 (diff) |
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/hist.c')
-rw-r--r-- | tools/perf/util/hist.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index e34fd248067d..baa55be64d9e 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -784,3 +784,62 @@ print_entries: | |||
784 | 784 | ||
785 | return ret; | 785 | return ret; |
786 | } | 786 | } |
787 | |||
788 | enum hist_filter { | ||
789 | HIST_FILTER__DSO, | ||
790 | HIST_FILTER__THREAD, | ||
791 | }; | ||
792 | |||
793 | void hists__filter_by_dso(struct hists *self, const struct dso *dso) | ||
794 | { | ||
795 | struct rb_node *nd; | ||
796 | |||
797 | self->nr_entries = self->stats.total = 0; | ||
798 | self->max_sym_namelen = 0; | ||
799 | |||
800 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { | ||
801 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | ||
802 | |||
803 | if (symbol_conf.exclude_other && !h->parent) | ||
804 | continue; | ||
805 | |||
806 | if (dso != NULL && (h->ms.map == NULL || h->ms.map->dso != dso)) { | ||
807 | h->filtered |= (1 << HIST_FILTER__DSO); | ||
808 | continue; | ||
809 | } | ||
810 | |||
811 | h->filtered &= ~(1 << HIST_FILTER__DSO); | ||
812 | if (!h->filtered) { | ||
813 | ++self->nr_entries; | ||
814 | self->stats.total += h->count; | ||
815 | if (h->ms.sym && | ||
816 | self->max_sym_namelen < h->ms.sym->namelen) | ||
817 | self->max_sym_namelen = h->ms.sym->namelen; | ||
818 | } | ||
819 | } | ||
820 | } | ||
821 | |||
822 | void hists__filter_by_thread(struct hists *self, const struct thread *thread) | ||
823 | { | ||
824 | struct rb_node *nd; | ||
825 | |||
826 | self->nr_entries = self->stats.total = 0; | ||
827 | self->max_sym_namelen = 0; | ||
828 | |||
829 | for (nd = rb_first(&self->entries); nd; nd = rb_next(nd)) { | ||
830 | struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node); | ||
831 | |||
832 | if (thread != NULL && h->thread != thread) { | ||
833 | h->filtered |= (1 << HIST_FILTER__THREAD); | ||
834 | continue; | ||
835 | } | ||
836 | h->filtered &= ~(1 << HIST_FILTER__THREAD); | ||
837 | if (!h->filtered) { | ||
838 | ++self->nr_entries; | ||
839 | self->stats.total += h->count; | ||
840 | if (h->ms.sym && | ||
841 | self->max_sym_namelen < h->ms.sym->namelen) | ||
842 | self->max_sym_namelen = h->ms.sym->namelen; | ||
843 | } | ||
844 | } | ||
845 | } | ||