diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-04-24 03:37:26 -0400 |
---|---|---|
committer | Jiri Olsa <jolsa@kernel.org> | 2014-04-24 10:31:25 -0400 |
commit | 9283ba9bd77a6940ecad8721429131d773c704b8 (patch) | |
tree | efa5bfd5cf02d5043ff0e6f3e387576ff208d662 | |
parent | ae993efc9c6bd109b027d2799a442892067e9230 (diff) |
perf hists: Add a couple of hists stat helper functions
Add hists__{reset,inc}_[filter_]stats() functions to cleanup accesses
to hist stats (for output). Note that number of samples in the stat
is not handled here since it belongs to the input stage.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1398327843-31845-5-git-send-email-namhyung@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
-rw-r--r-- | tools/perf/builtin-diff.c | 5 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 59 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 1 |
3 files changed, 40 insertions, 25 deletions
diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index c9cc771f182a..52d91ac4e6c8 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c | |||
@@ -573,10 +573,7 @@ static void hists__compute_resort(struct hists *hists) | |||
573 | hists->entries = RB_ROOT; | 573 | hists->entries = RB_ROOT; |
574 | next = rb_first(root); | 574 | next = rb_first(root); |
575 | 575 | ||
576 | hists->nr_entries = 0; | 576 | hists__reset_stats(hists); |
577 | hists->nr_non_filtered_entries = 0; | ||
578 | hists->stats.total_period = 0; | ||
579 | hists->stats.total_non_filtered_period = 0; | ||
580 | hists__reset_col_len(hists); | 577 | hists__reset_col_len(hists); |
581 | 578 | ||
582 | while (next != NULL) { | 579 | while (next != NULL) { |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index f5b388e50265..b675857883a2 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -317,16 +317,6 @@ static struct hist_entry *hist_entry__new(struct hist_entry *template) | |||
317 | return he; | 317 | return he; |
318 | } | 318 | } |
319 | 319 | ||
320 | void hists__inc_stats(struct hists *hists, struct hist_entry *h) | ||
321 | { | ||
322 | if (!h->filtered) { | ||
323 | hists->nr_non_filtered_entries++; | ||
324 | hists->stats.total_non_filtered_period += h->stat.period; | ||
325 | } | ||
326 | hists->nr_entries++; | ||
327 | hists->stats.total_period += h->stat.period; | ||
328 | } | ||
329 | |||
330 | static u8 symbol__parent_filter(const struct symbol *parent) | 320 | static u8 symbol__parent_filter(const struct symbol *parent) |
331 | { | 321 | { |
332 | if (symbol_conf.exclude_other && parent == NULL) | 322 | if (symbol_conf.exclude_other && parent == NULL) |
@@ -632,6 +622,35 @@ out: | |||
632 | return ret; | 622 | return ret; |
633 | } | 623 | } |
634 | 624 | ||
625 | static void hists__reset_filter_stats(struct hists *hists) | ||
626 | { | ||
627 | hists->nr_non_filtered_entries = 0; | ||
628 | hists->stats.total_non_filtered_period = 0; | ||
629 | } | ||
630 | |||
631 | void hists__reset_stats(struct hists *hists) | ||
632 | { | ||
633 | hists->nr_entries = 0; | ||
634 | hists->stats.total_period = 0; | ||
635 | |||
636 | hists__reset_filter_stats(hists); | ||
637 | } | ||
638 | |||
639 | static void hists__inc_filter_stats(struct hists *hists, struct hist_entry *h) | ||
640 | { | ||
641 | hists->nr_non_filtered_entries++; | ||
642 | hists->stats.total_non_filtered_period += h->stat.period; | ||
643 | } | ||
644 | |||
645 | void hists__inc_stats(struct hists *hists, struct hist_entry *h) | ||
646 | { | ||
647 | if (!h->filtered) | ||
648 | hists__inc_filter_stats(hists, h); | ||
649 | |||
650 | hists->nr_entries++; | ||
651 | hists->stats.total_period += h->stat.period; | ||
652 | } | ||
653 | |||
635 | static void __hists__insert_output_entry(struct rb_root *entries, | 654 | static void __hists__insert_output_entry(struct rb_root *entries, |
636 | struct hist_entry *he, | 655 | struct hist_entry *he, |
637 | u64 min_callchain_hits) | 656 | u64 min_callchain_hits) |
@@ -675,9 +694,7 @@ void hists__output_resort(struct hists *hists) | |||
675 | next = rb_first(root); | 694 | next = rb_first(root); |
676 | hists->entries = RB_ROOT; | 695 | hists->entries = RB_ROOT; |
677 | 696 | ||
678 | hists->nr_non_filtered_entries = 0; | 697 | hists__reset_stats(hists); |
679 | hists->stats.total_period = 0; | ||
680 | hists->stats.total_non_filtered_period = 0; | ||
681 | hists__reset_col_len(hists); | 698 | hists__reset_col_len(hists); |
682 | 699 | ||
683 | while (next) { | 700 | while (next) { |
@@ -699,13 +716,13 @@ static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h | |||
699 | if (h->filtered) | 716 | if (h->filtered) |
700 | return; | 717 | return; |
701 | 718 | ||
702 | ++hists->nr_non_filtered_entries; | ||
703 | if (h->ms.unfolded) | 719 | if (h->ms.unfolded) |
704 | hists->nr_non_filtered_entries += h->nr_rows; | 720 | hists->nr_non_filtered_entries += h->nr_rows; |
705 | h->row_offset = 0; | 721 | h->row_offset = 0; |
706 | hists->stats.total_non_filtered_period += h->stat.period; | 722 | |
707 | hists->stats.nr_non_filtered_samples += h->stat.nr_events; | 723 | hists->stats.nr_non_filtered_samples += h->stat.nr_events; |
708 | 724 | ||
725 | hists__inc_filter_stats(hists, h); | ||
709 | hists__calc_col_len(hists, h); | 726 | hists__calc_col_len(hists, h); |
710 | } | 727 | } |
711 | 728 | ||
@@ -726,9 +743,9 @@ void hists__filter_by_dso(struct hists *hists) | |||
726 | { | 743 | { |
727 | struct rb_node *nd; | 744 | struct rb_node *nd; |
728 | 745 | ||
729 | hists->nr_non_filtered_entries = 0; | ||
730 | hists->stats.total_non_filtered_period = 0; | ||
731 | hists->stats.nr_non_filtered_samples = 0; | 746 | hists->stats.nr_non_filtered_samples = 0; |
747 | |||
748 | hists__reset_filter_stats(hists); | ||
732 | hists__reset_col_len(hists); | 749 | hists__reset_col_len(hists); |
733 | 750 | ||
734 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 751 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
@@ -760,9 +777,9 @@ void hists__filter_by_thread(struct hists *hists) | |||
760 | { | 777 | { |
761 | struct rb_node *nd; | 778 | struct rb_node *nd; |
762 | 779 | ||
763 | hists->nr_non_filtered_entries = 0; | ||
764 | hists->stats.total_non_filtered_period = 0; | ||
765 | hists->stats.nr_non_filtered_samples = 0; | 780 | hists->stats.nr_non_filtered_samples = 0; |
781 | |||
782 | hists__reset_filter_stats(hists); | ||
766 | hists__reset_col_len(hists); | 783 | hists__reset_col_len(hists); |
767 | 784 | ||
768 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 785 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
@@ -792,9 +809,9 @@ void hists__filter_by_symbol(struct hists *hists) | |||
792 | { | 809 | { |
793 | struct rb_node *nd; | 810 | struct rb_node *nd; |
794 | 811 | ||
795 | hists->nr_non_filtered_entries = 0; | ||
796 | hists->stats.total_non_filtered_period = 0; | ||
797 | hists->stats.nr_non_filtered_samples = 0; | 812 | hists->stats.nr_non_filtered_samples = 0; |
813 | |||
814 | hists__reset_filter_stats(hists); | ||
798 | hists__reset_col_len(hists); | 815 | hists__reset_col_len(hists); |
799 | 816 | ||
800 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { | 817 | for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) { |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index 51478c94d976..ef1ad7a948c0 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -116,6 +116,7 @@ void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel); | |||
116 | void hists__output_recalc_col_len(struct hists *hists, int max_rows); | 116 | void hists__output_recalc_col_len(struct hists *hists, int max_rows); |
117 | 117 | ||
118 | u64 hists__total_period(struct hists *hists); | 118 | u64 hists__total_period(struct hists *hists); |
119 | void hists__reset_stats(struct hists *hists); | ||
119 | void hists__inc_stats(struct hists *hists, struct hist_entry *h); | 120 | void hists__inc_stats(struct hists *hists, struct hist_entry *h); |
120 | void hists__inc_nr_events(struct hists *hists, u32 type); | 121 | void hists__inc_nr_events(struct hists *hists, u32 type); |
121 | void events_stats__inc(struct events_stats *stats, u32 type); | 122 | void events_stats__inc(struct events_stats *stats, u32 type); |