took invocations counting out of lambda

This commit is contained in:
Sander Hautvast 2018-03-29 14:22:21 +02:00
parent a00c2e10a4
commit e50989fb37

View file

@ -25,20 +25,19 @@ public class Registry {
private static SortedMap<Long, Report> sortedMethodsByDuration() {
SortedMap<Long, Report> sortedByTotal = new ConcurrentSkipListMap<>(Comparator.reverseOrder());
methods.forEach((name, results) -> {
LongAdder adder = new LongAdder();
long totalDuration = results.stream().peek((r) -> adder.increment()).mapToLong(r -> r.getDuration()).sum();
sortedByTotal.put(totalDuration, new Report(name, adder.longValue(), totalDuration));
methods.forEach((name, measurements) -> {
long totalDuration = measurements.stream().mapToLong(Method::getDuration).sum();
sortedByTotal.put(totalDuration, new Report(name, measurements.size(), totalDuration));
});
return sortedByTotal;
}
static class Report {
final String name;
final long invocations;
final int invocations;
final long totalDuration;
Report(String name, long invocations, long totalDuration) {
Report(String name, int invocations, long totalDuration) {
this.name = name;
this.invocations = invocations;
this.totalDuration = totalDuration;