diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-16 23:08:45 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-16 23:08:45 +0000 |
commit | b7fcc7c73e41b326fe4d85d81c49c50fa954c990 (patch) | |
tree | 2d2310bed191bdb565095526d8a14e813f2f2958 /src/yourkit | |
parent | 03b3f7d4a1995c735ba95080f7dc5e0c68d07ca3 (diff) | |
download | scala-b7fcc7c73e41b326fe4d85d81c49c50fa954c990.tar.gz scala-b7fcc7c73e41b326fe4d85d81c49c50fa954c990.tar.bz2 scala-b7fcc7c73e41b326fe4d85d81c49c50fa954c990.zip |
Some profiling infrastructure.
I avoided creating any dependency on yourkit. In addition, there was
no way to give arguments to the JVM without losing the ones defined in
ANT_OPTS, which has been a massive pain for a while. So there is now
"jvm.opts" which is simply appended to ANT_OPTS, e.g.
% ant -Djvm.opts=-verbose
[echo] Forking with JVM opts: -Xms1536M -Xmx2g -Xss1M -XX:MaxPermSize=192M -XX:+UseParallelGC -verbose
There is a minimal stub defining a profiler interface:
scala.tools.util.Profiling
Then the yourkit wrapper implements that interface. Once your locker has
been rebuilt once, you can do this:
ant yourkit.run
And it will build quick.lib/comp with profiling enabled, assuming it
can find the necessary files. See the yourkit.init target for values to
change: or ant -Dyourkit.home=/path/to/it might be enough.
Review by dragos.
Diffstat (limited to 'src/yourkit')
-rw-r--r-- | src/yourkit/scala/tools/util/YourkitProfiling.scala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/yourkit/scala/tools/util/YourkitProfiling.scala b/src/yourkit/scala/tools/util/YourkitProfiling.scala new file mode 100644 index 0000000000..d66cdc9ee1 --- /dev/null +++ b/src/yourkit/scala/tools/util/YourkitProfiling.scala @@ -0,0 +1,36 @@ +package scala.tools +package util + +import com.yourkit.api._ +import nsc.io._ + +class YourkitProfiling extends Profiling { + @volatile private var active = false + private var recordAllocation = false + lazy val controller = new Controller + + def startProfiling(): Unit = { + if (isActive) + return + + active = true + daemonize(true) { + controller.startCPUProfiling(ProfilingModes.CPU_SAMPLING, Controller.DEFAULT_FILTERS) + if (recordAllocation) + controller.startAllocationRecording(true, 100, false, 0) + } + } + + def captureSnapshot() = + daemonize(false)(controller.captureSnapshot(ProfilingModes.SNAPSHOT_WITH_HEAP)) + + def stopProfiling() = { + if (recordAllocation) + controller.stopAllocationRecording() + + controller.stopCPUProfiling() + active = false + } + + def isActive = active +}
\ No newline at end of file |