took invocations counting out of lambda
This commit is contained in:
parent
a00c2e10a4
commit
e50989fb37
1 changed files with 5 additions and 6 deletions
|
|
@ -25,20 +25,19 @@ public class Registry {
|
||||||
|
|
||||||
private static SortedMap<Long, Report> sortedMethodsByDuration() {
|
private static SortedMap<Long, Report> sortedMethodsByDuration() {
|
||||||
SortedMap<Long, Report> sortedByTotal = new ConcurrentSkipListMap<>(Comparator.reverseOrder());
|
SortedMap<Long, Report> sortedByTotal = new ConcurrentSkipListMap<>(Comparator.reverseOrder());
|
||||||
methods.forEach((name, results) -> {
|
methods.forEach((name, measurements) -> {
|
||||||
LongAdder adder = new LongAdder();
|
long totalDuration = measurements.stream().mapToLong(Method::getDuration).sum();
|
||||||
long totalDuration = results.stream().peek((r) -> adder.increment()).mapToLong(r -> r.getDuration()).sum();
|
sortedByTotal.put(totalDuration, new Report(name, measurements.size(), totalDuration));
|
||||||
sortedByTotal.put(totalDuration, new Report(name, adder.longValue(), totalDuration));
|
|
||||||
});
|
});
|
||||||
return sortedByTotal;
|
return sortedByTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Report {
|
static class Report {
|
||||||
final String name;
|
final String name;
|
||||||
final long invocations;
|
final int invocations;
|
||||||
final long totalDuration;
|
final long totalDuration;
|
||||||
|
|
||||||
Report(String name, long invocations, long totalDuration) {
|
Report(String name, int invocations, long totalDuration) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.invocations = invocations;
|
this.invocations = invocations;
|
||||||
this.totalDuration = totalDuration;
|
this.totalDuration = totalDuration;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue