use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat 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;
}
use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat 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;
}
use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat in project honest-profiler by jvm-profiling-tools.
the class FlatFilterTest method check.
private <U> void check(FlatGenerator gen, Target target, Comparison comparison, U value, ScenarioStraightFilter filter) {
try {
Flat filtered = gen.filter(flatFilter(target, comparison, value));
scenario.checkFlatAggregation(new FlatCheckAdapter(filtered), filter);
} catch (AssertionError ae) {
throw new AssertionError("Failure : Unfiltered =\n" + gen.getFlat(), ae);
}
}
use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat in project honest-profiler by jvm-profiling-tools.
the class FlatViewController method refresh.
// AbstractViewController Implementation
@Override
protected void refresh() {
flatProfile.clear();
Flat target = getTarget();
if (target != null) {
flatProfile.addAll(target.filter(getFilterSpecification()).getData());
flatTable.refresh();
}
refreshTable(flatTable);
flatTable.sort();
}
use of com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat in project honest-profiler by jvm-profiling-tools.
the class DescendantFlatAggregatorTest method checkMultipleDescendantsSingleThread.
// Descendants of intermediate node
private void checkMultipleDescendantsSingleThread(ThreadGrouping tg, FrameGrouping fg) {
Flat flat = get(SCENARIOS.get(1), tg, fg, T_01, F_05, F_04, F_03);
assertAggregationSizeEquals(flat, 2);
assertContains(flat, keyFor(fg, F_02), 0, 1);
assertContains(flat, keyFor(fg, F_01), 1, 1);
}
Aggregations