Search in sources :

Example 11 with Tree

use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree in project honest-profiler by jvm-profiling-tools.

the class AncestorTreeAggregatorTest method checkMultipleAncestorsTwoThreads.

// Descendants of intermediate node
private void checkMultipleAncestorsTwoThreads(ThreadGrouping tg, FrameGrouping fg) {
    Tree tree = get(SCENARIOS.get(5), tg, fg, F_03);
    int expected = tg == ALL_TOGETHER ? 1 : 2;
    // Leaf children are nodes representing aggregated thread info. So only 1 if all threads are aggregated
    // together.
    assertAggregationSizeEquals(tree, 3 + expected);
    assertContains(tree, 0, 2, keysFor(fg, F_03));
    assertContains(tree, 0, 2, keysFor(fg, F_03, F_04));
    assertContains(tree, 0, 2, keysFor(fg, F_03, F_04, F_05));
}
Also used : Tree(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree)

Example 12 with Tree

use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree in project honest-profiler by jvm-profiling-tools.

the class DescendantTreeAggregatorTest method checkLeafDescendants.

// Descendants of leaf node
private void checkLeafDescendants(ThreadGrouping tg, FrameGrouping fg) {
    Tree tree = get(SCENARIOS.get(0), tg, fg, F_01);
    assertAggregationSizeEquals(tree, 1);
    assertContains(tree, 1, 1, keysFor(fg, F_01));
}
Also used : Tree(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree)

Example 13 with Tree

use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree in project honest-profiler by jvm-profiling-tools.

the class DescendantTreeAggregatorTest method checkMultipleDescendantsTwoThreads.

// Descendants of intermediate node
private void checkMultipleDescendantsTwoThreads(ThreadGrouping tg, FrameGrouping fg) {
    Tree tree = get(SCENARIOS.get(5), tg, fg, F_03);
    assertAggregationSizeEquals(tree, 3);
    assertContains(tree, 0, 2, keysFor(fg, F_03));
    assertContains(tree, 0, 2, keysFor(fg, F_03, F_02));
    assertContains(tree, 2, 2, keysFor(fg, F_03, F_02, F_01));
}
Also used : Tree(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree)

Example 14 with Tree

use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree in project honest-profiler by jvm-profiling-tools.

the class DescendantTreeAggregatorTest method checkMultipleDescendantsSingleThread.

// Descendants of intermediate node
private void checkMultipleDescendantsSingleThread(ThreadGrouping tg, FrameGrouping fg) {
    Tree tree = get(SCENARIOS.get(1), tg, fg, F_03);
    assertAggregationSizeEquals(tree, 3);
    assertContains(tree, 0, 1, keysFor(fg, F_03));
    assertContains(tree, 0, 1, keysFor(fg, F_03, F_02));
    assertContains(tree, 1, 1, keysFor(fg, F_03, F_02, F_01));
}
Also used : Tree(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree)

Example 15 with Tree

use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree in project honest-profiler by jvm-profiling-tools.

the class AncestorTreeAggregator method addAncestors.

/**
 * Recursive method for aggregating the parents (and ancestors) of the {@link LeanNode}s which are aggregated by the
 * provided {@link Node} and adding them as children.
 * <p>
 * @param source the original {@link AggregationProfile}
 * @param child the input {@link Node} whose ancestors will be aggregated and added as children
 * @param tree the resulting {@link Tree}
 * @param grouping the key calculation grouping
 */
private void addAncestors(AggregationProfile source, Node child, Tree tree, CombinedGrouping grouping) {
    Map<String, Node> result = child.getAggregatedNodes().stream().map(node -> node.getParent()).filter(node -> node != null).distinct().collect(groupingBy(// Group LeanNodes by calculated key
    node -> grouping.apply(source, node), // Downstream collector, aggregates LeanNodes in a single group
    of(// Supplier, creates an empty Node
    () -> {
        Node node = new Node(tree);
        // Set the reference by default for all nodes to the global aggregation.
        node.setReference(source.getGlobalData());
        return node;
    }, // Accumulator, aggregates a LeanNode into the Entry accumulator
    (node, leanNode) -> {
        node.add(leanNode);
        node.setKey(grouping.apply(source, leanNode));
    }, // Combiner, combines two Nodes with the same key
    (node1, node2) -> node1.combine(node2))));
    // Add the aggregated parents as children to the Node, and recurse
    result.entrySet().forEach(mapEntry -> {
        // The "child" Node in the ancestor Tree has its parents (the values of the calculated map) as children.
        child.addChild(mapEntry.getValue());
        // Recursively add ancestors
        addAncestors(source, mapEntry.getValue(), tree, grouping);
    });
}
Also used : CombinedGrouping(com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping) LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode) Tree(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree) Map(java.util.Map) Aggregation(com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation) Keyed(com.insightfullogic.honest_profiler.core.aggregation.result.Keyed) Entry(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry) Node(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) AggregationProfile(com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile) Collector.of(java.util.stream.Collector.of) LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode) Node(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node)

Aggregations

Tree (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree)16 Node (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node)6 AggregationProfile (com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile)5 CombinedGrouping (com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping)5 LeanNode (com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode)5 Keyed (com.insightfullogic.honest_profiler.core.aggregation.result.Keyed)4 Map (java.util.Map)3 Collector.of (java.util.stream.Collector.of)3 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)3 Aggregation (com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation)2 Entry (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry)2 DiffNode (com.insightfullogic.honest_profiler.core.aggregation.result.diff.DiffNode)1 TreeDiff (com.insightfullogic.honest_profiler.core.aggregation.result.diff.TreeDiff)1 LeanProfile (com.insightfullogic.honest_profiler.core.profiles.lean.LeanProfile)1 NumericInfo (com.insightfullogic.honest_profiler.core.profiles.lean.info.NumericInfo)1 TreeCheckAdapter (com.insightfullogic.honest_profiler.framework.checker.TreeCheckAdapter)1 NodeTreeItem (com.insightfullogic.honest_profiler.ports.javafx.view.tree.NodeTreeItem)1 GraphicsContext (javafx.scene.canvas.GraphicsContext)1