summaryrefslogtreecommitdiff
path: root/inferno/data_types.py
diff options
context:
space:
mode:
Diffstat (limited to 'inferno/data_types.py')
-rw-r--r--inferno/data_types.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/inferno/data_types.py b/inferno/data_types.py
index deb9f51..35ef4c0 100644
--- a/inferno/data_types.py
+++ b/inferno/data_types.py
@@ -113,15 +113,16 @@ class FlameGraphCallSite(object):
self._get_next_callsite_id())
return child
- def trim_callchain(self, min_num_events):
+ def trim_callchain(self, min_num_events, max_depth, depth=0):
""" Remove call sites with num_events < min_num_events in the subtree.
Remaining children are collected in a list.
"""
- for key in self.child_dict:
- child = self.child_dict[key]
- if child.num_events >= min_num_events:
- child.trim_callchain(min_num_events)
- self.children.append(child)
+ if depth <= max_depth:
+ for key in self.child_dict:
+ child = self.child_dict[key]
+ if child.num_events >= min_num_events:
+ child.trim_callchain(min_num_events, max_depth, depth + 1)
+ self.children.append(child)
# Relese child_dict since it will not be used.
self.child_dict = None