Class StackFrameNode

java.lang.Object
com.helix.profiler.flamegraph.StackFrameNode

public class StackFrameNode extends Object
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 Details

    • StackFrameNode

      public StackFrameNode(String name, int depth, StackFrameNode parent)
      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

      public String getName()
    • getFrameName

      public String getFrameName()
    • getDepth

      public int getDepth()
    • getParent

      public StackFrameNode getParent()
    • getSelfValue

      public long getSelfValue()
    • getTotalValue

      public long getTotalValue()
    • incrementSelfValue

      public void incrementSelfValue(long delta)
    • incrementTotalValue

      public void incrementTotalValue(long delta)
    • getOrCreateChild

      public StackFrameNode getOrCreateChild(String childName)
      Retrieves or creates a child node for the given frame name.
      Parameters:
      childName - name of the child frame
      Returns:
      child StackFrameNode
    • getChild

      public StackFrameNode getChild(String childName)
      Retrieves an existing child by name, or null if absent.
    • getChildren

      public Collection<StackFrameNode> getChildren()
      Returns an unmodifiable collection of all child nodes.
    • getChildrenSortedByTotal

      public List<StackFrameNode> 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

      public StackFrameNode getRoot()
      Finds the root of this flame graph trie.
    • findNode

      public StackFrameNode findNode(String frameName)
      Recursively searches for a node with the specified name in this subtree.
    • toTreeString

      public String toTreeString()
      Renders a human-readable hierarchical tree string of this node and its descendants.
    • toString

      public String toString()
      Overrides:
      toString in class Object