summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/partest/scala/tools/partest/instrumented/Instrumentation.scala10
-rw-r--r--src/partest/scala/tools/partest/instrumented/Profiler.java4
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>();
}