Linux 是否有用于 Java 的控制台分析器?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11123727/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a console profiler for Java?
提问by R.Omar
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.
是否有类似 gprof 的 Java 分析器可以从 Linux 的终端运行?我找到的所有工具都是 GUI 程序,我需要从终端运行它。
回答by Karthik Kumar Viswanathan
I use jconsole for that. http://docs.oracle.com/javase/6/docs/technotes/tools/share/jconsole.html
我为此使用 jconsole。http://docs.oracle.com/javase/6/docs/technotes/tools/share/jconsole.html
回答by Akhi
If you want it for profiling and monitoring. You can use Jvisualvm.
如果你想要它进行分析和监控。您可以使用Jvisualvm。
from App site:
来自应用程序站点:
DESCRIPTIONJava VisualVM is an intuitive graphical user interface that provides detailed information about Java technology-based applications (Java applications) while they are running on a given Java Virtual Machine (JVM*). The name Java VisualVM comes from the fact that Java VisualVM provides information about the JVM software visually.
描述Java VisualVM 是一个直观的图形用户界面,它提供有关基于 Java 技术的应用程序(Java 应用程序)在给定 Java 虚拟机 (JVM*) 上运行时的详细信息。Java VisualVM 的名称来源于 Java VisualVM 以可视方式提供有关 JVM 软件的信息。
Java VisualVM combines several monitoring, troubleshooting, and profiling utilities into a single tool. For example, most of the functionality offered by the standalone tools jmap, jinfo, jstat and jstack have been integrated into Java VisualVM. Other functionalities, such as some of those offered by the JConsole tool, can be added as optional plug-ins.
Java VisualVM 将多个监控、故障排除和分析实用程序组合到一个工具中。例如,独立工具 jmap、jinfo、jstat 和 jstack 提供的大部分功能都已集成到 Java VisualVM 中。其他功能,例如 JConsole 工具提供的一些功能,可以作为可选插件添加。
EDIT:As you want a terminal approach.Refer this link Triggering a Javadump. It describes creation of java dump.
编辑:因为你想要一个终端方法。参考这个链接Triggering a Javadump。它描述了 java 转储的创建。
回答by ataylor
The JVM has a built-in profiler called HPROF. You can enable it on the command line like this:
JVM 有一个名为HPROF的内置分析器。您可以像这样在命令行上启用它:
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.
当程序完成时,这会将配置文件信息转储到文本文件中。除了分析 CPU 使用情况外,它还可以跟踪堆使用情况。
回答by William Louth
JXInsight/OpenCore has term/shell reporting plugins (top, queues, stacks,...) that will output its metering and metrics data at regular intervals. It is also possible to access this information using the Open API which allows inspection of the model in real-time within the JVM or offline using a snapshot file handle. Both are supported via Plugin API which it how the top, queues,... ones work.
JXInsight/OpenCore 具有 term/shell 报告插件(top、queues、stacks...),它们将定期输出其计量和指标数据。还可以使用 Open API 访问此信息,该 API 允许在 JVM 内实时检查模型或使用快照文件句柄离线检查模型。两者都通过插件 API 支持,它是如何工作的。
http://www.jinspired.com/products/opencore(commercial)
http://www.jinspired.com/products/opencore(商业)
Is there a technical reason you can't use a GUI? Is it just a preference driven by a workflow habit? If not then you can always try out our FREE JXInsight/Opus Java Edition - a highly efficient and scalable code level latency performance measurement solution for rapidly identifying hotspots within Java and JRuby applications.
是否存在无法使用 GUI 的技术原因?它只是由工作流程习惯驱动的偏好吗?如果没有,您可以随时试用我们的免费 JXInsight/Opus Java 版 - 一种高效且可扩展的代码级延迟性能测量解决方案,用于快速识别 Java 和 JRuby 应用程序中的热点。
http://www.jinspired.com/products/opus
http://www.jinspired.com/products/opus
Note: I am the product architect of both products.
注意:我是这两个产品的产品架构师。
回答by MRalwasser
The open-source tool jvmtopcontains a terminal profiler and might be worth a look:
开源工具jvmtop包含一个终端分析器,可能值得一看:
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()