From f5bd52038dd7ded5178dadd35713f44995911022 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 2 Apr 2020 15:35:18 +0200 Subject: [PATCH] support node.stack in nflxprofile format --- app/common/flame_graph.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/common/flame_graph.py b/app/common/flame_graph.py index dec6f1f..70ec67a 100644 --- a/app/common/flame_graph.py +++ b/app/common/flame_graph.py @@ -27,13 +27,18 @@ def _get_regular_stacks(nflxprofile_nodes, root_node_id): while queue: (nflxprofile_node_id, parent_node_id) = queue.pop(0) nflxprofile_node = nflxprofile_nodes[nflxprofile_node_id] - if not parent_node_id: - stacks[nflxprofile_node_id] = [ - (nflxprofile_node.function_name, nflxprofile_node.libtype) - ] + + if parent_node_id: + stacks[nflxprofile_node_id] = stacks[parent_node_id] + else: + stacks[nflxprofile_node_id] = [] + + if nflxprofile_node.stack: + for frame in nflxprofile_node.stack: + stacks[nflxprofile_node_id].append((frame.function_name, frame.libtype)) else: - stacks[nflxprofile_node_id] = stacks[parent_node_id] + \ - [(nflxprofile_node.function_name, nflxprofile_node.libtype)] + stacks[nflxprofile_node_id].append((nflxprofile_node.function_name, nflxprofile_node.libtype)) + for child_id in nflxprofile_node.children: queue.append((child_id, nflxprofile_node_id))