From e50989fb370bc89e2dc0953530f9db20f977b4c0 Mon Sep 17 00:00:00 2001 From: Sander Hautvast Date: Thu, 29 Mar 2018 14:22:21 +0200 Subject: [PATCH] took invocations counting out of lambda --- src/main/java/perfix/Registry.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/perfix/Registry.java b/src/main/java/perfix/Registry.java index 918a8f3..d81077e 100644 --- a/src/main/java/perfix/Registry.java +++ b/src/main/java/perfix/Registry.java @@ -25,20 +25,19 @@ public class Registry { private static SortedMap sortedMethodsByDuration() { SortedMap 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;