eclipse 了解visualvm分析器中的CPU时间

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

Understanding CPU time in visualvm profiler

javaeclipsevisualvm

提问by peter.murray.rust

I have started to use visualvm for profiling my application which I launch in Eclipse. Then I launch visualvm which initially gives believable results.

我已经开始使用 visualvm 来分析我在 Eclipse 中启动的应用程序。然后我启动了visualvm,它最初给出了可信的结果。

enter image description here

在此处输入图片说明

After some time two processes appear in the monitor which consume huge amounts of time.

一段时间后,两个进程出现在监视器中,它们消耗了大量时间。

enter image description here

在此处输入图片说明

I have not deliberately invoked these. After a time they disappear. Are they an artefact of the profiling process and do I need to worry?

我没有刻意援引这些。一段时间后,它们消失了。它们是分析过程的产物吗,我需要担心吗?

Very few of my routines appear in the profile, mainly the libraries they call. Is there a way of showing which routines call the most heavily used ones?

我的例程很少出现在配置文件中,主要是它们调用的库。有没有办法显示哪些例程调用最常用的例程?

回答by Tomas Hurka

It is better to start with CPU sampling, if you don't know which part of the code is slow. Once you know better (based on the sampling results) what is going on, you can profile just part of your application, which is slow. You need to set profiling roots and instrumentation filter and don't forget to take the snapshot of collected results. See Profiling With VisualVM, Part 1and Profiling With VisualVM, Part 2to get more information about profiling and how to set profiling roots and instrumentation filter.

如果不知道代码的哪一部分慢,最好从 CPU 采样开始。一旦您更好地了解(基于采样结果)正在发生的事情,您就可以只分析应用程序的一部分,这很慢。您需要设置分析根和检测过滤器,并且不要忘记拍摄收集结果的快照。请参阅使用 VisualVM 进行分析,第 1 部分使用 VisualVM 进行分析,第 2 部分,以获取有关分析以及如何设置分析根和检测过滤器的更多信息。

回答by Peter Lawrey

VisualVM uses Java to perform it's work. This means you will see some artefacts which relate to the RMI calls it makes. You can ignore them.

VisualVM 使用 Java 来执行它的工作。这意味着您将看到一些与它所做的 RMI 调用相关的人工制品。你可以忽略它们。

I use YourKit which doesn't do this, but it's not free ;)

我使用不这样做的 YourKit,但它不是免费的 ;)

回答by greedybuddha

VisualVM will track all methods being called by the java program it's monitoring, so either your program or one of its libraries is calling those methods. VisualVM is also connecting to it so there might be some small artifacts.

VisualVM 将跟踪它正在监视的 Java 程序调用的所有方法,因此您的程序或其库之一正在调用这些方法。VisualVM 也连接到它,所以可能会有一些小工件。

As for searching, probably the easiest way is to filter by your own packages. There is a space at the bottom where you can enter those so you can see which of your own methods is really taking time. Also you should pay attention to which thread you are in, usually you will want to look at the whatever is your "main" thread. The other threads are interesting but won't always give you the best idea of how your program behaves.

至于搜索,可能最简单的方法是按您自己的包进行过滤。底部有一个空间,您可以在其中输入它们,以便您可以查看自己的哪种方法真正需要时间。此外,您应该注意您所在的线程,通常您会想要查看您的“主”线程。其他线程很有趣,但并不总是让您对程序的行为方式有最好的了解。