如何使用 java -prof 选项获取在 Tomcat 上运行的 Java 程序的分析输出? [英] How to get profiling output of java programs running on Tomcat using java -prof option?

查看:39
本文介绍了如何使用 java -prof 选项获取在 Tomcat 上运行的 Java 程序的分析输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在java程序中,用java profiler运行程序会产生分析输出Ex- java -prof 类文件名

in java programs, running the programs with java profiler will generate profiling output Ex- java -prof classfile_name

如何获得在 Tomcat 上运行的 Java 程序的相同分析输出?

How to get same profiling output of java programs running on Tomcat?

我想得到这样的分析输出

I want to get an profiling output like this

count callee caller time ,就像这样在分析输出中

count callee caller time , like this in profiling output

1 java.util.LinkedHashMap.init()V java.util.HashMap.(IF)V 0

1 java.util.LinkedHashMap.init()V java.util.HashMap.(IF)V 0

你能告诉我如何为在 Tomcat 上运行的程序获得这样的输出吗?

Can you tell me how to get an output like this for programs running on Tomcat?

推荐答案

Tomcat 也只是一个 Java 应用程序,因此您可以通过在 中定义 JAVA_OPTS 环境变量来添加相同的 VM 参数Tomcat 发行版的 startup.bat/startup.sh.

Tomcat is also just a Java application, so you can add the same VM parameters by defining the JAVA_OPTS environment variable in startup.bat/startup.sh of your Tomcat distribution.

但是,我真的建议使用真正的分析器,有几种免费和商业替代品.主要的免费解决方案是 visualvm,作为商业解决方案,我推荐 JProfiler(免责声明:我的公司开发了该工具).

However, I would really recommend to use a real profiler, there are several free and commercial alternatives. The major free one is visualvm and as a commercial solution I recommend JProfiler (disclaimer: my company develops that tool).

在这些分析器中,寻找热点"视图,它会显示您正在寻找的信息类型.

In those profilers, look for the "Hot spot" views which will show you the kind of information that you are looking for.

这篇关于如何使用 java -prof 选项获取在 Tomcat 上运行的 Java 程序的分析输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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