performance 如何测试java应用程序的性能瓶颈?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37929/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 16:37:25  来源:igfitidea点击:

How to test java application for performance bottlenecks?

javaperformance

提问by Niyaz

I am reviewing a big java application to see if there are any performance bottlenecks. The real problem is that I cannot pinpoint the performance issues to any single module. The whole application is slow as such.

我正在一个大型 Java 应用程序,以查看是否存在任何性能瓶颈。真正的问题是我无法确定任何单个模块的性能问题。整个应用程序因此很慢。

Is there some tool/technique I can use to help me out in this?

是否有一些工具/技术可以帮助我解决这个问题?

采纳答案by Bartosz Bierkowski

Try using a profiler on your running code. It should help you identify the bottlenecks. Try jprofileror Netbeans profiler

尝试在您的运行代码上使用分析器。它应该可以帮助您确定瓶颈。尝试jprofilerNetbeans 分析器

回答by wvdschel

I'm often happy enough using Java -Xprof. This gives you a sorted list of the functions your code spends most of its time in.

我经常很高兴使用Java -Xprof. 这为您提供了代码花费大部分时间的功能的排序列表。

回答by HadleyHope

If you are running on Java 6 you can use the supplied monitoring tools

如果您在 Java 6 上运行,则可以使用提供的监控工具

回答by Tnilsson

For testing/development purposes, you can download Oracle JRockit Mission Control for free from thissite. (Requires Login, but accounts can be set up with any email adress)

出于测试/开发目的,您可以从站点免费下载 Oracle JRockit Mission Control 。(需要登录,但可以使用任何电子邮件地址设置帐户)

Docs Here. It will allow you to find hotspots, memory leaks and much more.

文档在这里。它将允许您找到热点、内存泄漏等等。

回答by peceps

YourKitis a excelent java profiler (not free).

YourKit是一个优秀的 Java 分析器(不是免费的)。

回答by Riking

As we see from How can I profile C++ code running in Linux?, the most statistically significant approach is to use a stack profiler.

正如我们从如何分析在 Linux 中运行的 C++ 代码所看到的 ,最具有统计意义的方法是使用堆栈分析器。

Well, Java runs in the JVM, so getting a stack useful for C code won't be useful for us (it'll get the JVM stuff, not your code). Fortunately, Java has jstack! http://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jstack.html

好吧,Java 在 JVM 中运行,因此获得对 C 代码有用的堆栈对我们没有用(它将获得 JVM 内容,而不是您的代码)。幸运的是,Java 有jstackhttp://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jstack.html

It'll give you a bunch of threads, like the GarbageCollector. Don't worry about those, just look at where your threads are.

它会给你一堆线程,比如 GarbageCollector。不要担心这些,只要看看你的线程在哪里。