Skip to content
Snippets Groups Projects
Commit 02d5ba2f authored by Pawel Dziepak's avatar Pawel Dziepak Committed by Pekka Enberg
Browse files

trace: filter memory analyzer output by minimum allocation count

parent 4c995e5e
No related branches found
No related tags found
No related merge requests found
......@@ -155,8 +155,10 @@ class TreeKey(object):
def __hash__(self):
return self.this.__hash__()
def filter_min_count(min_count):
return lambda node: node.key.alloc >= min_count
def show_results(mallocs):
def show_results(mallocs, node_filters):
root = tree.TreeNode(TreeKey('All', None))
lost = 0
......@@ -189,4 +191,10 @@ def show_results(mallocs):
def formatter(key):
return key.key.__str__()
tree.print_tree(root, formatter)
def node_filter(*args):
for filter in node_filters:
if not filter(*args):
return False
return True
tree.print_tree(root, formatter, node_filter=node_filter)
......@@ -111,9 +111,14 @@ def list_trace(args):
def mem_analys(args):
mallocs = {}
node_filters = []
if args.min_count:
node_filters.append(memory_analyzer.filter_min_count(args.min_count))
with get_trace_reader(args) as reader:
memory_analyzer.process_records(mallocs, reader.get_traces())
memory_analyzer.show_results(mallocs)
memory_analyzer.show_results(mallocs, node_filters)
def add_time_slicing_options(parser):
group = parser.add_argument_group('time slicing')
......@@ -560,6 +565,8 @@ if __name__ == "__main__":
Requires memory_* tracepoints enabled.
""")
add_trace_source_options(cmd_memory_analyzer)
cmd_memory_analyzer.add_argument("--min-count", action='store', type=int,
help="show only allocations at least as frequent as the specified threshold")
cmd_memory_analyzer.set_defaults(func=mem_analys, paginate=True)
args = parser.parse_args()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment