diff options
author | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-07-26 11:43:04 +0200 |
---|---|---|
committer | Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com> | 2012-07-26 11:55:00 +0200 |
commit | 6c734305a9bad126b38c1235c0ef629c3137769b (patch) | |
tree | 8eb2379165efc95ebd240c3b34d7456a635b22ff | |
parent | 9e04e2365a7210f7e671137d8f70e475688b0885 (diff) | |
download | scala-6c734305a9bad126b38c1235c0ef629c3137769b.tar.gz scala-6c734305a9bad126b38c1235c0ef629c3137769b.tar.bz2 scala-6c734305a9bad126b38c1235c0ef629c3137769b.zip |
Fix `Instrumentation.getStatistics` method in partest.
The previous implementation was wrong because it
would always enable profiling after call to
`Instrumenation.getStatistics` method. Now we are
checking the profiling status and enable it again
only when it was enabled before.
Review by @phaller.
-rw-r--r-- | src/partest/scala/tools/partest/instrumented/Instrumentation.scala | 10 | ||||
-rw-r--r-- | src/partest/scala/tools/partest/instrumented/Profiler.java | 4 |
2 files changed, 12 insertions, 2 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>(); } |