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() {
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue