From a31806518856ae3db8e2a470211e01eadfc335ce Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 24 Aug 2022 11:28:24 +0200 Subject: [PATCH] Improve output quality --- src/main/java/de/steamwar/Sampler.java | 15 +++++++++++++++ src/main/java/de/steamwar/Trace.java | 10 +++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/steamwar/Sampler.java b/src/main/java/de/steamwar/Sampler.java index e8240e5..21ee318 100644 --- a/src/main/java/de/steamwar/Sampler.java +++ b/src/main/java/de/steamwar/Sampler.java @@ -37,11 +37,26 @@ public class Sampler { omittedMethods.add("java.util.Iterator.forEachRemaining"); omittedMethods.add("java.lang.Iterable.forEach"); omittedMethods.add("java.util.ArrayList.forEach"); + omittedMethods.add("java.util.ArrayList$ArrayListSpliterator.forEachRemaining"); omittedMethods.add("java.util.Map.forEach"); + omittedMethods.add("java.util.HashMap$EntrySpliterator.forEachRemaining"); + omittedMethods.add("java.util.Spliterators$IteratorSpliterator.forEachRemaining"); + omittedMethods.add("java.util.Spliterators$ArraySpliterator.forEachRemaining"); omittedMethods.add("java.util.concurrent.ThreadPoolExecutor$Worker.run"); omittedMethods.add("java.util.concurrent.ThreadPoolExecutor.runWorker"); omittedMethods.add("java.util.concurrent.CompletableFuture$Completion.run"); omittedMethods.add("java.util.concurrent.CompletableFuture$AsyncSupply.run"); + omittedMethods.add("java.util.stream.ReferencePipeline.forEach"); + omittedMethods.add("java.util.stream.ReferencePipeline$7$1.forEach"); + omittedMethods.add("java.util.stream.ReferencePipeline$3$1.accept"); + omittedMethods.add("java.util.stream.AbstractPipeline.evaluate"); + omittedMethods.add("java.util.stream.AbstractPipeline.wrapAndCopyInto"); + omittedMethods.add("java.util.stream.AbstractPipeline.copyInto"); + omittedMethods.add("java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential"); + omittedMethods.add("java.util.stream.ForEachOps$ForEachOp.evaluateSequential"); + omittedMethods.add("java.util.stream.ReduceOps$ReduceOp.evaluateSequential"); + omittedMethods.add("java.util.stream.ReduceOps$1ReducingSink.accept"); + omittedMethods.add("java.util.stream.Streams$StreamBuilderImpl.forEachRemaining"); } private final Map traces = new HashMap<>(); diff --git a/src/main/java/de/steamwar/Trace.java b/src/main/java/de/steamwar/Trace.java index 5da7fc7..93e50d9 100644 --- a/src/main/java/de/steamwar/Trace.java +++ b/src/main/java/de/steamwar/Trace.java @@ -40,7 +40,11 @@ public class Trace { } private String percentage(int value) { - return df.format(value * 100.0 / sampler.getSampleRuns()); + return df.format(value * 100.0 / ownSampleRuns()); + } + + private String time(int value) { + return df.format(value * Sampler.SAMPLING_SPEED / 1e9); } public void toDot(OutputStreamWriter writer) throws IOException { @@ -59,13 +63,13 @@ public class Trace { if (a > 255) a = 255; - writer.append(String.valueOf(id)).append(" [fillcolor=\"#").append(String.format("%02X", r)).append(String.format("%02X", g)).append(String.format("%02X", b)).append(String.format("%02X", a)).append("\",label=\"").append(name).append("\\n").append(percentage(ownSampleRuns())).append("% ").append(df.format(ownSampleRuns() * Sampler.SAMPLING_SPEED / 1e9)).append("s\\nR").append(percentage(runnable)).append("% B").append(percentage(blocked)).append("% W").append(percentage(waiting)).append("%\"];\n"); + writer.append(String.valueOf(id)).append(" [fillcolor=\"#").append(String.format("%02X", r)).append(String.format("%02X", g)).append(String.format("%02X", b)).append(String.format("%02X", a)).append("\",label=\"").append(name).append("\\n").append(time(ownSampleRuns())).append("s ").append(percentage(ownSampleRuns())).append("%\\nR").append(percentage(runnable)).append("% B").append(percentage(blocked)).append("% W").append(percentage(waiting)).append("%\"];\n"); for (Map.Entry entry : predecessors.entrySet()) { if (entry.getKey().filtered() || entry.getValue() < Sampler.FILTER) continue; - writer.append(String.valueOf(entry.getKey().id)).append(" -> ").append(String.valueOf(id)).append(" [label=\"").append(percentage(entry.getValue())).append("%\",weight=").append(String.valueOf(entry.getValue())).append("];\n"); + writer.append(String.valueOf(entry.getKey().id)).append(" -> ").append(String.valueOf(id)).append(" [label=\"").append(time(entry.getValue())).append("s\\n").append(percentage(entry.getValue())).append("%\",weight=").append(String.valueOf(entry.getValue())).append("];\n"); } } }