Class ItemTreeToolkit
- java.lang.Object
-
- org.openjdk.jmc.flightrecorder.rules.tree.ItemTreeToolkit
-
public final class ItemTreeToolkit extends java.lang.Object
Toolkit for working with item trees.
-
-
Constructor Summary
Constructors Constructor Description ItemTreeToolkit()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
appendLayerBreakdown(java.lang.StringBuilder report, IQuantity firstLayerDuration, LayerBreakdownVisitor.LayerBreakdown breakdown)
static void
appendLayeredBreakdown(java.lang.StringBuilder report, ITreeNode<IItem> root, int maxDepth)
Reports all encapsulation layers.static void
appendLongestBreakdown(java.lang.StringBuilder report, ITreeNode<IItem> root)
Renders a report of the longest encapsulating event chain.static int
getDepth(ITreeNode<?> node)
Returns the number of ancestors the node has.(package private) static boolean
hasDuration(IItem item)
static java.lang.String
printTree(ITreeNode<IItem> node)
private static java.lang.Object
toString(IQuantity duration)
-
-
-
Method Detail
-
printTree
public static java.lang.String printTree(ITreeNode<IItem> node)
- Returns:
- A String representation of the tree. Useful for debugging.
-
hasDuration
static boolean hasDuration(IItem item)
-
appendLongestBreakdown
public static void appendLongestBreakdown(java.lang.StringBuilder report, ITreeNode<IItem> root)
Renders a report of the longest encapsulating event chain.If we have A -> (B->D, C->E) and B has longer duration than C, the report will be A => B => D.
- Parameters:
report
- the report to write toroot
- the root node to start from
-
appendLayeredBreakdown
public static void appendLayeredBreakdown(java.lang.StringBuilder report, ITreeNode<IItem> root, int maxDepth)
Reports all encapsulation layers.If A -> (B->D, C->E), the report will show:
- Layer 1: A (100 %)
- Layer 2: B (X %), C (Y %)
- Layer 3: D (U %), E (V %)
- Parameters:
report
- the report to write toroot
- the root node to start the analysis frommaxDepth
- maximum number of layers to analyze
-
appendLayerBreakdown
private static void appendLayerBreakdown(java.lang.StringBuilder report, IQuantity firstLayerDuration, LayerBreakdownVisitor.LayerBreakdown breakdown)
-
toString
private static java.lang.Object toString(IQuantity duration)
-
getDepth
public static int getDepth(ITreeNode<?> node)
Returns the number of ancestors the node has.- Parameters:
node
- the node for which to calculate the depth- Returns:
- the depth of the node from the root
-
-