Skip to content

Commit

Permalink
Keep aggregated LeanNodes in Entry instead of frames
Browse files Browse the repository at this point in the history
More useful for calculating backtraces, and possibly other features.
  • Loading branch information
PhRX committed Jan 26, 2017
1 parent d0057b9 commit cd2fb8f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
Expand Up @@ -9,7 +9,6 @@
import com.insightfullogic.honest_profiler.core.aggregation.result.straight.Entry; 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.aggregation.result.straight.Flat;
import com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode; import com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode;
import com.insightfullogic.honest_profiler.core.profiles.lean.NumericInfo;


/** /**
* Aggregator which takes an {@link AggregationProfile}, and uses the data to aggregate the values into a list of * Aggregator which takes an {@link AggregationProfile}, and uses the data to aggregate the values into a list of
Expand All @@ -31,11 +30,13 @@ public Flat<String> aggregate(AggregationProfile input, LeanNode reference)


input.getFqmnLinks().values().forEach(link -> input.getFqmnLinks().values().forEach(link ->
{ {
NumericInfo sum = link.getSiblings().values().stream().flatMap(Collection::stream) Entry<String> entry = link.getSiblings().values().stream().flatMap(Collection::stream)
.map(LeanNode::getData) .collect(
.collect(NumericInfo::new, (x, y) -> x.add(y), (x, y) -> x.add(y)); () -> new Entry<String>(link.getFqmn(), aggregation),
(x, y) -> x.add(y),
(x, y) -> x.combine(y));


result.add(new Entry<>(link.getFqmn(), sum, aggregation)); result.add(entry);
}); });


return aggregation; return aggregation;
Expand Down
Expand Up @@ -108,10 +108,10 @@ private Collector<LeanNode, Node<String>, Node<String>> getCollector(Tree<String
// Supplier // Supplier
() -> new Node<>(tree), () -> new Node<>(tree),
// Accumulator // Accumulator
(entry, node) -> (accumulator, node) ->
{ {
entry.add(profile.getFqmn(node), node.getFrame(), node.getData()); accumulator.add(profile.getFqmn(node), node);
add(tree, profile, entry, node); // Recursion here ! add(tree, profile, accumulator, node); // Recursion here !
}, },
// Combiner // Combiner
(e1, e2) -> e1.combine(e2)); (e1, e2) -> e1.combine(e2));
Expand Down
Expand Up @@ -5,7 +5,7 @@


import com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation; import com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation;
import com.insightfullogic.honest_profiler.core.aggregation.result.Keyed; import com.insightfullogic.honest_profiler.core.aggregation.result.Keyed;
import com.insightfullogic.honest_profiler.core.profiles.lean.FrameInfo; import com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode;
import com.insightfullogic.honest_profiler.core.profiles.lean.NumericInfo; import com.insightfullogic.honest_profiler.core.profiles.lean.NumericInfo;


/** /**
Expand All @@ -17,13 +17,13 @@ public class Entry<K> implements Keyed<K>
private Aggregation<K, ? extends Keyed<K>> aggregation; private Aggregation<K, ? extends Keyed<K>> aggregation;
private K key; private K key;
private NumericInfo data; private NumericInfo data;
private List<FrameInfo> frames; private List<LeanNode> aggregatedNodes;


protected <T extends Keyed<K>> Entry(Aggregation<K, T> aggregation) protected <T extends Keyed<K>> Entry(Aggregation<K, T> aggregation)
{ {
this.data = new NumericInfo(); this.data = new NumericInfo();
this.aggregation = aggregation; this.aggregation = aggregation;
this.frames = new ArrayList<>(); this.aggregatedNodes = new ArrayList<>();
} }


public <T extends Keyed<K>> Entry(K key, Aggregation<K, T> aggregation) public <T extends Keyed<K>> Entry(K key, Aggregation<K, T> aggregation)
Expand All @@ -37,17 +37,17 @@ public <T extends Keyed<K>> Entry(K key, NumericInfo data, Aggregation<K, T> agg
this.key = key; this.key = key;
this.data = data.copy(); this.data = data.copy();
this.aggregation = aggregation; this.aggregation = aggregation;
this.frames = new ArrayList<>(); this.aggregatedNodes = new ArrayList<>();


} }


public <T extends Keyed<K>> Entry(K key, public <T extends Keyed<K>> Entry(K key,
NumericInfo data, NumericInfo data,
Aggregation<K, T> aggregation, Aggregation<K, T> aggregation,
FrameInfo frame) LeanNode node)
{ {
this(key, data, aggregation); this(key, data, aggregation);
frames.add(frame); aggregatedNodes.add(node);
} }


@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Expand Down Expand Up @@ -77,9 +77,9 @@ public NumericInfo getData()
return data; return data;
} }


public List<FrameInfo> getFrames() public List<LeanNode> getAggregatedNodes()
{ {
return frames; return this.aggregatedNodes;
} }


public long getSelfTime() public long getSelfTime()
Expand Down Expand Up @@ -129,23 +129,23 @@ public int getRefCnt()
return aggregation == null ? 0 : getReference().getTotalCnt(); return aggregation == null ? 0 : getReference().getTotalCnt();
} }


public void add(FrameInfo frame, NumericInfo newData) public void add(LeanNode node)
{ {
frames.add(frame); aggregatedNodes.add(node);
data.add(newData); data.add(node.getData());
} }


protected void copyInto(Entry<K> other) protected void copyInto(Entry<K> other)
{ {
other.aggregation = aggregation; other.aggregation = aggregation;
other.key = key; other.key = key;
other.data = data.copy(); other.data = data.copy();
other.frames = new ArrayList<>(frames); other.aggregatedNodes = new ArrayList<>(aggregatedNodes);
} }


public void combine(Entry<K> other) public void combine(Entry<K> other)
{ {
frames.addAll(other.frames); aggregatedNodes.addAll(other.aggregatedNodes);
data.add(other.data); data.add(other.data);
} }


Expand Down
Expand Up @@ -9,7 +9,7 @@


import com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation; import com.insightfullogic.honest_profiler.core.aggregation.result.Aggregation;
import com.insightfullogic.honest_profiler.core.aggregation.result.Keyed; import com.insightfullogic.honest_profiler.core.aggregation.result.Keyed;
import com.insightfullogic.honest_profiler.core.profiles.lean.FrameInfo; import com.insightfullogic.honest_profiler.core.profiles.lean.LeanNode;
import com.insightfullogic.honest_profiler.core.profiles.lean.NumericInfo; import com.insightfullogic.honest_profiler.core.profiles.lean.NumericInfo;


/** /**
Expand Down Expand Up @@ -72,10 +72,10 @@ public int getDescendantDepth()
return depth; return depth;
} }


public void add(K key, FrameInfo frame, NumericInfo data) public void add(K key, LeanNode node)
{ {
super.setKey(key); super.setKey(key);
super.add(frame, data); super.add(node);
} }


public Node<K> combine(Node<K> other) public Node<K> combine(Node<K> other)
Expand Down

0 comments on commit cd2fb8f

Please sign in to comment.