Is there a gprof-like profiler for Java that can be run from the terminal in Linux? All tools I have found are GUI programs and I need run it from the terminal.
The Eclipse Test & Performance Tools Platform (TPTP) Profiling tool can be used to profile Eclipse plug-ins, local Java(TM) applications or complex applications running on multiple hosts and different platforms.
The HotSpot profiler looks for "hot spots" in the code, i.e. methods that the JVM spends a significant amount of time running, and then compiles those methods into native generated code.
The JVM has a built-in profiler called HPROF. You can enable it on the command line like this:
java -agentlib:hprof=file=hprof.txt,cpu=samples MyClass
This will dump profile information out to a text file when the program finishes. In addition to profiling CPU usage, it can also track heap usage.
The open-source tool jvmtop contains a terminal profiler and might be worth a look:
JvmTop 0.7.0 alpha - 15:16:34, amd64, 8 cpus, Linux 2.6.32-27, load avg 0.41
http://code.google.com/p/jvmtop
Profiling PID 24015: org.apache.catalina.startup.Bootstrap
36.16% ( 57.57s) hudson.model.AbstractBuild.calcChangeSet()
30.36% ( 48.33s) hudson.scm.SubversionChangeLogParser.parse()
7.14% ( 11.37s) org.kohsuke.stapler.jelly.JellyClassTearOff.parseScript()
6.25% ( 9.95s) net.sf.json.JSONObject.write()
3.13% ( 4.98s) ....kohsuke.stapler.jelly.CustomTagLibrary.loadJellyScri()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With