Search in sources :

Example 11 with Node

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

the class FlameViewCanvas method render.

// AbstractFlameCanvas Implementation
@Override
public void render(final Tree tree) {
    clearBlocks();
    methodMap = tree.getSource().getSource().getMethodInfoMap();
    final GraphicsContext ctx = getGraphics();
    // // Total number of samples
    long nrSamples = tree.getSource().getGlobalData().getTotalCnt();
    // TODO Reaggregate when filtering so the width can be calculated properly. Now we have bla
    // Total number of samples in the leaves (the Tree may be filtered so we can't use the AggregationProfile global
    // data)
    // long nrSamples = rootNode.flattenDescendants()
    // .filter(node -> node.getChildren().size() == 0)
    // .flatMap(node -> node.getAggregatedNodes().stream())
    // .mapToLong(node -> node.getData().getTotalCnt()).sum();
    // Any frame will be represented with its width proportional to its total sample count divided by the profile
    // total sample count
    double colWidth = getWidth() / nrSamples;
    // Nr Rows = max depth of a stack. The root Node represents all threads, but since the descendant depth of a
    // Node without children is defined as 0, this works out fine.
    int nrRows = tree.getData().stream().mapToInt(Node::getDescendantDepth).max().getAsInt() + 1;
    double rowHeight = max(getHeight() / nrRows, ctx.getFont().getSize());
    double startX = 0;
    double startY = getHeight() - rowHeight;
    for (Node node : tree.getData()) {
        startX += renderNode(ctx, node, 0, colWidth, rowHeight, startX, startY);
    }
}
Also used : GraphicsContext(javafx.scene.canvas.GraphicsContext) LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode) Node(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node)

Example 12 with Node

use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node 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)

Example 13 with Node

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

the class AncestorTreeAggregator method aggregate.

// Aggregator Implementation
/**
 * @see SubAggregator#aggregate(Object)
 */
@Override
public Tree aggregate(Entry input) {
    Aggregation<Keyed<String>> aggregation = input.getAggregation();
    AggregationProfile source = aggregation.getSource();
    CombinedGrouping grouping = aggregation.getGrouping();
    Tree result = new Tree(source, input.getAggregation().getGrouping());
    Node root = new Node(input);
    result.getData().add(root);
    addAncestors(source, root, result, grouping);
    return result;
}
Also used : AggregationProfile(com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile) LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode) Node(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node) Tree(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree) Keyed(com.insightfullogic.honest_profiler.core.aggregation.result.Keyed) CombinedGrouping(com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping)

Aggregations

Node (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node)13 Tree (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree)6 LeanNode (com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode)6 AggregationProfile (com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile)5 CombinedGrouping (com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping)5 Keyed (com.insightfullogic.honest_profiler.core.aggregation.result.Keyed)4 Entry (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry)3 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 TreeTableViewCheckAdapter (com.insightfullogic.honest_profiler.framework.checker.TreeTableViewCheckAdapter)2 ContextMenu (javafx.scene.control.ContextMenu)2 TreeTableView (javafx.scene.control.TreeTableView)2 FrameGrouping (com.insightfullogic.honest_profiler.core.aggregation.grouping.FrameGrouping)1 ThreadGrouping (com.insightfullogic.honest_profiler.core.aggregation.grouping.ThreadGrouping)1 DiffEntry (com.insightfullogic.honest_profiler.core.aggregation.result.diff.DiffEntry)1 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