diff options
author | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-07-29 07:18:00 -0700 |
---|---|---|
committer | Josh Suereth <Joshua.Suereth@gmail.com> | 2012-07-29 07:18:00 -0700 |
commit | bb5388273724d79b70373f73300a82d54bfe50b6 (patch) | |
tree | 8371f484f00d6231bd7154d80e96aa9b69c916c3 /src/partest | |
parent | ce9e98177e7a36327cf4a2d33772b626e9e2e753 (diff) | |
parent | 6c734305a9bad126b38c1235c0ef629c3137769b (diff) | |
download | scala-bb5388273724d79b70373f73300a82d54bfe50b6.tar.gz scala-bb5388273724d79b70373f73300a82d54bfe50b6.tar.bz2 scala-bb5388273724d79b70373f73300a82d54bfe50b6.zip |
Merge pull request #996 from gkossakowski/instrumentation-fixes
Partest instrumentation fixes
Diffstat (limited to 'src/partest')
3 files changed, 15 insertions, 3 deletions
diff --git a/src/partest/scala/tools/partest/instrumented/Instrumentation.scala b/src/partest/scala/tools/partest/instrumented/Instrumentation.scala index f29a7f90fd..3589df60f6 100644 --- a/src/partest/scala/tools/partest/instrumented/Instrumentation.scala +++ b/src/partest/scala/tools/partest/instrumented/Instrumentation.scala @@ -54,14 +54,20 @@ object Instrumentation { def startProfiling(): Unit = Profiler.startProfiling() def stopProfiling(): Unit = Profiler.stopProfiling() def resetProfiling(): Unit = Profiler.resetProfiling() + def isProfiling(): Boolean = Profiler.isProfiling() def getStatistics: Statistics = { - Profiler.stopProfiling() + val isProfiling = Profiler.isProfiling() + if (isProfiling) { + Profiler.stopProfiling() + } val stats = Profiler.getStatistics().asScala.toSeq.map { case (trace, count) => MethodCallTrace(trace.className, trace.methodName, trace.methodDescriptor) -> count.intValue } val res = Map(stats: _*) - Profiler.startProfiling() + if (isProfiling) { + Profiler.startProfiling() + } res } diff --git a/src/partest/scala/tools/partest/instrumented/Profiler.java b/src/partest/scala/tools/partest/instrumented/Profiler.java index 215bdbba08..0c87060794 100644 --- a/src/partest/scala/tools/partest/instrumented/Profiler.java +++ b/src/partest/scala/tools/partest/instrumented/Profiler.java @@ -55,6 +55,10 @@ public class Profiler { isProfiling = false; } + public static boolean isProfiling() { + return isProfiling; + } + public static void resetProfiling() { counts = new HashMap<MethodCallTrace, Integer>(); } diff --git a/src/partest/scala/tools/partest/javaagent/ASMTransformer.java b/src/partest/scala/tools/partest/javaagent/ASMTransformer.java index 643c683002..09cd485d6b 100644 --- a/src/partest/scala/tools/partest/javaagent/ASMTransformer.java +++ b/src/partest/scala/tools/partest/javaagent/ASMTransformer.java @@ -21,7 +21,9 @@ public class ASMTransformer implements ClassFileTransformer { // we instrument all classes from empty package (!className.contains("/") || // we instrument all classes from scala package - className.startsWith("scala/")); + className.startsWith("scala/") || + // we instrument all classes from `instrumented` package + className.startsWith("instrumented/")); } public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) { |