Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flat and Tree aggregators reworked, support multiple groupings
This is the groundwork for switching aggregations between within-thread aggregation, over-thread aggregation, by method name or method + line Nr or by BCI. - Groupings introduced for determining the key for an item which is used for grouping LeanNodes when aggregating - Got rid of the K typing for the key, it wasn't going to be used, and it makes things easier to fix it as a String, especially for the new Groupings which had to group into a String anyway -
- Loading branch information
Showing
37 changed files
with
577 additions
and
455 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
...com/insightfullogic/honest_profiler/core/aggregation/aggregator/FlatByFqmnAggregator.java
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
...om/insightfullogic/honest_profiler/core/aggregation/aggregator/FlatProfileAggregator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,69 @@ | |||
package com.insightfullogic.honest_profiler.core.aggregation.aggregator; | |||
|
|||
import static java.util.stream.Collector.of; | |||
import static java.util.stream.Collectors.groupingBy; | |||
import static java.util.stream.Collectors.toList; | |||
|
|||
import java.util.Map; | |||
|
|||
import com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile; | |||
import com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping; | |||
import com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry; | |||
import com.insightfullogic.honest_profiler.core.aggregation.result.straight.Flat; | |||
import com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode; | |||
import com.insightfullogic.honest_profiler.core.profiles.lean.LeanProfile; | |||
import com.insightfullogic.honest_profiler.core.profiles.lean.LeanThreadNode; | |||
|
|||
/** | |||
* Aggregator which takes an {@link AggregationProfile}, and uses the data to aggregate the values into a {@link Flat} | |||
* aggregation. | |||
* | |||
* NOTE : The {@link LeanThreadNode}s are also aggregated, so the resulting {@link Flat} will contain {@link Entry}s | |||
* aggregating the thread-level data as well ! | |||
*/ | |||
public class FlatProfileAggregator implements ProfileAggregator<Entry> | |||
{ | |||
/** | |||
* 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); | |||
|
|||
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).collect( | |||
groupingBy( | |||
// Group LeanNodes by calculated key | |||
node -> grouping.apply(input, node), | |||
// Downstream collector, collects LeanNodes in a single group | |||
of( | |||
// Supplier, creates an empty Entry | |||
() -> new Entry(result), | |||
// Accumulator, aggregates a LeanNode into the Entry accumulator | |||
(x, y) -> x.add(y), | |||
// Combiner, combines two Entries with the same key | |||
(x, y) -> x.combine(y)))); | |||
|
|||
// Add the aggregated Entries to the result list, after setting their key and reference. The key is the | |||
// Map.Entry key, the Entry is the Map.Entry value. | |||
result.getData().addAll(entryMap.entrySet().stream().map(mapEntry -> | |||
{ | |||
Entry entry = mapEntry.getValue(); | |||
entry.setKey(mapEntry.getKey()); | |||
// By default, the reference for Entries is the global, over-thread aggregation. | |||
entry.setReference(input.getGlobalData()); | |||
return entry; | |||
}).collect(toList())); | |||
|
|||
return result; | |||
} | |||
} |
24 changes: 24 additions & 0 deletions
24
...va/com/insightfullogic/honest_profiler/core/aggregation/aggregator/ProfileAggregator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
package com.insightfullogic.honest_profiler.core.aggregation.aggregator; | |||
|
|||
import com.insightfullogic.honest_profiler.core.aggregation.AggregationProfile; | |||
import com.insightfullogic.honest_profiler.core.aggregation.grouping.CombinedGrouping; | |||
import com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation; | |||
import com.insightfullogic.honest_profiler.core.aggregation.result.Keyed; | |||
|
|||
/** | |||
* Generic interface for aggregation functions which operate on the entire {@link AggregationProfile}. An Aggregator | |||
* aggregates an input {@link AggregationProfile} into an {@link Aggregation} containing results of type <T>, which are | |||
* keyed by a String. | |||
* | |||
* @param <T> the type of the content items in the resulting {@link Aggregation} | |||
*/ | |||
public interface ProfileAggregator<T extends Keyed<String>> | |||
{ | |||
/** | |||
* Aggregate the provided {@link AggregationProfile}. | |||
* | |||
* @param input the {@link AggregationProfile} to be aggregated | |||
* @return the resulting {@link Aggregation} | |||
*/ | |||
Aggregation<T> aggregate(AggregationProfile input, CombinedGrouping grouping); | |||
} |
Oops, something went wrong.