Package com.helix.profiler.flamegraph
Class StackFrameNode
java.lang.Object
com.helix.profiler.flamegraph.StackFrameNode
Hierarchical prefix trie node representing a stack frame in a flame graph call tree.
Thread-safe for lock-free concurrent sample ingestion and cumulative percentage calculations.
-
Constructor Summary
ConstructorsConstructorDescriptionStackFrameNode(String name, int depth, StackFrameNode parent) Constructs a new StackFrameNode. -
Method Summary
Modifier and TypeMethodDescriptionRecursively searches for a node with the specified name in this subtree.Retrieves an existing child by name, or null if absent.Returns an unmodifiable collection of all child nodes.Returns a list of children sorted by total value descending.doubleCalculates the cumulative percentage of the total profile represented by this frame.intgetDepth()getName()getOrCreateChild(String childName) Retrieves or creates a child node for the given frame name.getRoot()Finds the root of this flame graph trie.doubleCalculates the self percentage of the total profile terminating specifically at this frame.longlongvoidincrementSelfValue(long delta) voidincrementTotalValue(long delta) booleanisLeaf()booleanisRoot()toString()Renders a human-readable hierarchical tree string of this node and its descendants.
-
Constructor Details
-
StackFrameNode
Constructs a new StackFrameNode.- Parameters:
name- frame name (e.g., class.method)depth- call stack depth (0 for root)parent- parent node reference, or null for root
-
-
Method Details
-
getName
-
getFrameName
-
getDepth
public int getDepth() -
getParent
-
getSelfValue
public long getSelfValue() -
getTotalValue
public long getTotalValue() -
incrementSelfValue
public void incrementSelfValue(long delta) -
incrementTotalValue
public void incrementTotalValue(long delta) -
getOrCreateChild
Retrieves or creates a child node for the given frame name.- Parameters:
childName- name of the child frame- Returns:
- child StackFrameNode
-
getChild
Retrieves an existing child by name, or null if absent. -
getChildren
Returns an unmodifiable collection of all child nodes. -
getChildrenSortedByTotal
Returns a list of children sorted by total value descending. -
isRoot
public boolean isRoot() -
isLeaf
public boolean isLeaf() -
getCumulativePercentage
public double getCumulativePercentage()Calculates the cumulative percentage of the total profile represented by this frame.- Returns:
- percentage from 0.0 to 100.0
-
getSelfPercentage
public double getSelfPercentage()Calculates the self percentage of the total profile terminating specifically at this frame.- Returns:
- percentage from 0.0 to 100.0
-
getRoot
Finds the root of this flame graph trie. -
findNode
Recursively searches for a node with the specified name in this subtree. -
toTreeString
Renders a human-readable hierarchical tree string of this node and its descendants. -
toString
-