Search in sources :

Example 1 with Entry

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

the class DescendantFlatAggregator method aggregate.

/**
 * This method aggregates all descendants of a {@link Node} into a {@link Flat}, using the original
 * {@link CombinedGrouping} from the {@link Tree} the {@link Node} belongs to.
 *
 * @see SubAggregator#aggregate(Object)
 */
@Override
public Flat aggregate(Node parent) {
    Aggregation<Keyed<String>> aggregation = parent.getAggregation();
    AggregationProfile source = aggregation.getSource();
    CombinedGrouping grouping = aggregation.getGrouping();
    Flat result = new Flat(source, grouping);
    result.getData().addAll(// Create a stream of all descendant nodes, and aggregate according to the Grouping
    parent.flattenDescendants().collect(groupingBy(// Group Nodes by their key
    Node::getKey, // Downstream collector, aggregates the Nodes in a single group
    of(// Supplier, creates an empty Entry
    () -> {
        Entry entry = new Entry(aggregation);
        // Set the reference by default for all nodes to the global aggregation.
        entry.setReference(source.getGlobalData());
        return entry;
    }, // Accumulator, adds a Node to the accumulator Node
    (x, y) -> x.combine(y), // Combiner, combines to entries
    (x, y) -> x.combine(y)))).values());
    return result;
}
Also used : AggregationProfile(com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile) Entry(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry) Flat(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat) Keyed(com.insightfullogic.honest_profiler.core.aggregation.result.Keyed) CombinedGrouping(com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping)

Example 2 with Entry

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

the class FlatProfileAggregator method aggregate.

/**
 * Aggregates an {@link AggregationProfile} into a {@link Flat}. The {@link CombinedGrouping} specifies which
 * {@link LeanNode}s are aggregated together.
 *
 * @see ProfileAggregator#aggregate(AggregationProfile, CombinedGrouping)
 */
@Override
public Flat aggregate(AggregationProfile input, CombinedGrouping grouping) {
    // Prepare result.
    Flat result = new Flat(input, grouping);
    LeanProfile source = input.getSource();
    // Flatten all LeanNodes into a Stream, then collect it into a Map where the key is calculated by the groupings,
    // and the value is the aggregation of the LeanNodes corresponding to the key.
    Map<String, Entry> entryMap = source.getThreads().values().stream().flatMap(LeanNode::flatten).filter(node -> !node.isThreadNode()).collect(groupingBy(// Group LeanNodes by calculated key
    node -> grouping.apply(input, node), // Downstream collector, aggregates LeanNodes in a single group
    of(// Supplier, creates an empty Entry
    () -> new Entry(result), // Accumulator, aggregates a LeanNode into the Entry accumulator
    (entry, leanNode) -> entry.add(leanNode), // Combiner, combines two Entries with the same key
    (entry1, entry2) -> entry1.combine(entry2))));
    // Add the aggregated Entries to the result list, after setting their key and reference.
    result.getData().addAll(entryMap.entrySet().stream().map(mapEntry -> {
        Entry entry = mapEntry.getValue();
        // The key must be set explicitly here because it isn't set in the collector.
        entry.setKey(mapEntry.getKey());
        // Set the reference by default for all nodes to the global aggregation.
        entry.setReference(input.getGlobalData());
        return entry;
    }).collect(toList()));
    return result;
}
Also used : LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode) Collectors.toList(java.util.stream.Collectors.toList) CombinedGrouping(com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping) LeanNode(com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode) Map(java.util.Map) Entry(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) Flat(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat) AggregationProfile(com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile) LeanProfile(com.insightfullogic.honest_profiler.core.profiles.lean.LeanProfile) Collector.of(java.util.stream.Collector.of) Entry(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry) LeanProfile(com.insightfullogic.honest_profiler.core.profiles.lean.LeanProfile) Flat(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat)

Example 3 with Entry

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

the class AncestorTreeAggregatorTest method get.

private Tree get(SimplifiedLogScenario scenario, ThreadGrouping tg, FrameGrouping fg, StackFrame frame) {
    AncestorTreeAggregator aggregator = new AncestorTreeAggregator();
    FlatGenerator gen = new FlatGenerator(tg, fg);
    scenario.executeAndEnd(gen);
    Entry entry = gen.getEntry(keyFor(fg, frame));
    return aggregator.aggregate(entry);
}
Also used : Entry(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry) FlatGenerator(com.insightfullogic.honest_profiler.framework.generator.FlatGenerator)

Example 4 with Entry

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

the class DescendantTreeAggregatorTest method get.

private Tree get(SimplifiedLogScenario scenario, ThreadGrouping tg, FrameGrouping fg, StackFrame frame) {
    DescendantTreeAggregator aggregator = new DescendantTreeAggregator();
    FlatGenerator gen = new FlatGenerator(tg, fg);
    scenario.executeAndEnd(gen);
    Entry entry = gen.getEntry(keyFor(fg, frame));
    return aggregator.aggregate(entry);
}
Also used : Entry(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry) FlatGenerator(com.insightfullogic.honest_profiler.framework.generator.FlatGenerator)

Example 5 with Entry

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

the class FlatViewQuickFilterTest method checkResult.

private void checkResult(FxRobot robot, ScenarioStraightFilter... filters) {
    asList(FrameGrouping.values()).forEach(fg -> {
        selectFrameGrouping(robot, fg, "#flat");
        TableView<Entry> tableView = getFlatTableView(robot);
        scenario.checkFlatAggregation(new FlatTableViewCheckAdapter(ALL_TOGETHER, fg, tableView), filters);
    });
}
Also used : Entry(com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry) FlatTableViewCheckAdapter(com.insightfullogic.honest_profiler.framework.checker.FlatTableViewCheckAdapter)

Aggregations

Entry (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry)8 AggregationProfile (com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile)4 CombinedGrouping (com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping)4 Flat (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat)3 Keyed (com.insightfullogic.honest_profiler.core.aggregation.result.Keyed)2 LeanNode (com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode)2 LeanProfile (com.insightfullogic.honest_profiler.core.profiles.lean.LeanProfile)2 FlatTableViewCheckAdapter (com.insightfullogic.honest_profiler.framework.checker.FlatTableViewCheckAdapter)2 FlatGenerator (com.insightfullogic.honest_profiler.framework.generator.FlatGenerator)2 Map (java.util.Map)2 Collector.of (java.util.stream.Collector.of)2 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)2 FlatProfileAggregator (com.insightfullogic.honest_profiler.core.aggregation.aggregator.FlatProfileAggregator)1 FilterSpecification (com.insightfullogic.honest_profiler.core.aggregation.filter.FilterSpecification)1 CombinedGrouping.combine (com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping.combine)1 FrameGrouping (com.insightfullogic.honest_profiler.core.aggregation.grouping.FrameGrouping)1 ThreadGrouping (com.insightfullogic.honest_profiler.core.aggregation.grouping.ThreadGrouping)1 Aggregation (com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation)1 Node (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Node)1 Tree (com.insightfullogic.honest_profiler.core.aggregation.result.straight.Tree)1