简体   繁体   English

JvisualVM中采样器和分析器之间的区别是什么?

[英]what's the difference between sampler and profiler in JvisualVM?

I found there are two plug-in in JvisualVM, one is sampler and another is profiler. 我发现JvisualVM中有两个插件,一个是采样器,另一个是探测器。

I also found they have a similar UI, however the results have a big difference, so what's the difference meaning for them? 我还发现他们有类似的用户界面,但结果有很大差异,那么对他们来说有什么不同呢?

And why they have a big difference? 为什么他们有很大的不同?

In general: 一般来说:

A profiler is running all the time, so it gives you the complete call stack; 分析器一直在运行,因此它为您提供完整的调用堆栈; at any given point in time. 在任何给定的时间点。

A sampler only takes "snapshots" at distinct point in times. 采样器只在不同的时间点拍摄“快照”。

Thing is: when you "profile" everything, then that slows down your JVM significantly; 事情是:当你“描述”所有东西时,那会大大减慢你的JVM; and it creates enormous amounts of data within a few seconds. 它创建了一个几秒钟内庞大的数据量。 Think about: the profiler will write down each and any method invocation that takes place! 想一想:探查器会记下每个发生的方法调用!

So typically, you initially use a sampler, when you have "no idea" what is going on within your application. 通常,当您“不知道”应用程序中发生了什么时,您最初使用的是采样器。 And then you just hope that the samples tell you something; 然后你只希望样品告诉你一些事情; like "hey, within our 10 000 samples, we are in that one method most of the time, why is that?" 比如“嘿,在我们的10000个样本中,我们大部分时间都采用这种方法,为什么会这样?” But as soon as you have a better understanding what you are "hunting" for, you would try to do a full profiler run in order to capture the whole call chain that leads into some method. 但是一旦你更好地理解了你正在寻找的东西,你就会尝试进行一个完整的分析器运行,以捕获导致某种方法的整个调用链。

And then there is some "middle ground" - where you profile "everything" but exclude things. 然后有一些“中间立场” - 你在其中描述“一切”但排除的东西。 In other words: most profilers allow you to say "do not profile methods in classes in this or that package". 换句话说:最剖析让你说“ 型材在这个或那个包类的方法”。 But of course - excluding packages/hierarchies only makes sense when you already have a pretty good feeling which direction you intend to investigate. 但是当然 - 排除包/层次结构只有在你已经非常好地感觉到你打算调查哪个方向时才有意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM