在命令行中剖析正在运行的Java应用程序 [英] Profiling a running Java application in command line

查看:222
本文介绍了在命令行中剖析正在运行的Java应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我常常使用VisualVM来运行Java应用程序,但需要X在计算机上运行

I profile running Java applications often with VisualVM but it needs X to run on the machine

我知道我可以通过管理端口连接,但这将是离线采样

I know I can connect through management port but that will be an offline sampled profiling which is not enough for me.

因此,我正在寻找一个解决方案,通过它可以从命令行界面分析正在运行的Java应用程序的方法的CPU使用情况,线。

So I'm looking for a solution with which I can profile the CPU usage of the methods of a running Java application from command-line. It's enough for me to collect data on the server and then the collected data can be analyzed on a different machine.

更新:

看来我需要更具体。我想从命令行配置一个正在运行的Java应用程序,我不想停止它并重新运行它。

It seems I need to be more specific. I want to profile a running Java application from command line, I don't want to stop it and rerun it.

推荐答案

a href =https://github.com/patric-r/jvmtop/blob/master/doc/ConsoleProfiler.md> jvmtop 是从命令行进行概要分析的一个方便的工具。无需停止jvm:

jvmtop is a convenient tool for profiling from the commandline. No need to stop the jvm:

jvmtop.sh --profile <PID>

将会给你这样的输出,当应用程序运行时会更新:

Will give you output like this which will be updating while the app runs:

  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()
  ...

优点是它不需要使用仪器。将被改变的jvm的类将不会被改变。

The advantage is that it does not take the use of instrumentation. The classes of the to-be-profiled jvm will not be altered.

这篇关于在命令行中剖析正在运行的Java应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆