diff options
Diffstat (limited to 'internal/tui/flamegraph/zoom.go')
| -rw-r--r-- | internal/tui/flamegraph/zoom.go | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/internal/tui/flamegraph/zoom.go b/internal/tui/flamegraph/zoom.go new file mode 100644 index 0000000..7a3aa42 --- /dev/null +++ b/internal/tui/flamegraph/zoom.go @@ -0,0 +1,39 @@ +package flamegraph + +import "strings" + +func findNodeByPath(root *snapshotNode, path string) *snapshotNode { + if root == nil { + return nil + } + if path == "" { + return root + } + parts := strings.Split(path, pathSeparator) + if len(parts) == 0 { + return root + } + rootName := frameName(root.Name, 0) + if parts[0] == rootName { + parts = parts[1:] + } + + node := root + for _, part := range parts { + next := findChildByName(node, part) + if next == nil { + return nil + } + node = next + } + return node +} + +func findChildByName(node *snapshotNode, name string) *snapshotNode { + for _, child := range node.Children { + if child.Name == name || frameName(child.Name, 1) == name { + return child + } + } + return nil +} |
