diff --git a/DiSLProject2022/src-profiler/ex5/Instrumentation.java b/DiSLProject2022/src-profiler/ex5/Instrumentation.java index 81d5dca..3c44945 100644 --- a/DiSLProject2022/src-profiler/ex5/Instrumentation.java +++ b/DiSLProject2022/src-profiler/ex5/Instrumentation.java @@ -18,7 +18,6 @@ public class Instrumentation { Profiler.addUnsafeAllocation(); } - @Before(marker = BodyMarker.class, scope = "sun.misc.Unsafe.allocateInstance") static void handleUnsafeAllocationsPraiseTheSun() { Profiler.addUnsafeAllocation(); diff --git a/DiSLProject2022/src-profiler/ex9/Profiler.java b/DiSLProject2022/src-profiler/ex9/Profiler.java index 7157950..c0e85a2 100644 --- a/DiSLProject2022/src-profiler/ex9/Profiler.java +++ b/DiSLProject2022/src-profiler/ex9/Profiler.java @@ -6,7 +6,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; public final class Profiler { - private static final ConcurrentMap> callLog = new ConcurrentHashMap<>(); + private static final ConcurrentMap> callLog = new ConcurrentHashMap<>(); static { Runtime.getRuntime().addShutdownHook(new Thread(Profiler::print)); @@ -16,16 +16,16 @@ public final class Profiler { } public static void logCall(final Thread thread, final String methodName) { - final List list = callLog.computeIfAbsent(thread.getName(), ignored -> new LinkedList<>()); + final List list = callLog.computeIfAbsent(thread, ignored -> new LinkedList<>()); // thread safe, as once a thread accesses its own list access to said list is non-concurrent list.add(methodName); } private static void print() { - for (final String threadName : callLog.keySet()) { - System.out.printf("=== %s ===\n", threadName); - callLog.get(threadName).forEach(System.out::println); + for (final Thread thread : callLog.keySet()) { + System.out.printf("=== %s ===\n", thread.getName()); + callLog.get(thread).forEach(System.out::println); } } }