13
0

Improve output
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
Lixfel 2022-08-24 10:24:47 +02:00
Ursprung 80937cdfd8
Commit 6da60b9165
2 geänderte Dateien mit 6 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -10,7 +10,7 @@ import java.util.concurrent.locks.LockSupport;
public class Sampler { public class Sampler {
public static final long SAMPLING_SPEED = 1000000; public static final long SAMPLING_SPEED = 1000000;
public static final double FILTER = 0.01; public static final int FILTER = 10;
private static final Set<String> waitingMethods = new HashSet<>(); private static final Set<String> waitingMethods = new HashSet<>();
static { static {
@ -38,14 +38,9 @@ public class Sampler {
omittedMethods.add("java.lang.Iterable.forEach"); omittedMethods.add("java.lang.Iterable.forEach");
omittedMethods.add("java.util.ArrayList.forEach"); omittedMethods.add("java.util.ArrayList.forEach");
omittedMethods.add("java.util.Map.forEach"); omittedMethods.add("java.util.Map.forEach");
omittedMethods.add("java.util.concurrent.ThreadPoolExecutor$Worker.run");
//TODO: Rework to concrete functions omittedMethods.add("java.util.concurrent.ThreadPoolExecutor.runWorker");
omittedMethods.add("jdk.internal"); omittedMethods.add("java.util.concurrent.CompletableFuture$Completion.run");
omittedMethods.add("java.util.stream");
omittedMethods.add("java.util.Spliterators");
omittedMethods.add("java.util.ArrayList$ArrayListSpliterator");
omittedMethods.add("java.util.AbstractList$RandomAccessSpliterator");
omittedMethods.add("java.util.concurrent");
} }
private final Map<String, Trace> traces = new HashMap<>(); private final Map<String, Trace> traces = new HashMap<>();
@ -93,8 +88,6 @@ public class Sampler {
} }
private void run() { private void run() {
Thread autoStopper = new Thread(this::stop, "SamplerStop");
Runtime.getRuntime().addShutdownHook(autoStopper);
long lastTime = System.nanoTime(); long lastTime = System.nanoTime();
while(!shutdown) { while(!shutdown) {
sample(); sample();
@ -103,12 +96,6 @@ public class Sampler {
LockSupport.parkNanos(SAMPLING_SPEED - currentTime + lastTime); LockSupport.parkNanos(SAMPLING_SPEED - currentTime + lastTime);
lastTime = currentTime; lastTime = currentTime;
} }
try {
Runtime.getRuntime().removeShutdownHook(autoStopper);
} catch (IllegalStateException e) {
// ignored
}
} }
private void sample() { private void sample() {

Datei anzeigen

@ -30,7 +30,7 @@ public class Trace {
} }
private boolean filtered() { private boolean filtered() {
return Arrays.stream(samples).sum() / (double) sampler.getSampleRuns() < Sampler.FILTER; return Arrays.stream(samples).sum() < Sampler.FILTER;
} }
public void add(Thread.State state, Trace predecessor) { public void add(Thread.State state, Trace predecessor) {
@ -62,7 +62,7 @@ public class Trace {
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(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");
for (Map.Entry<Trace, Integer> entry : predecessors.entrySet()) { for (Map.Entry<Trace, Integer> entry : predecessors.entrySet()) {
if (entry.getKey().filtered() || entry.getValue() / (double)sampler.getSampleRuns() < Sampler.FILTER) if (entry.getKey().filtered() || entry.getValue() < Sampler.FILTER)
continue; 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(percentage(entry.getValue())).append("%\",weight=").append(String.valueOf(entry.getValue())).append("];\n");