简体   繁体   English

如何在提供网页请求时识别哪些方法正在吃饭?

[英]How to identify which methods are eating time while serving request for a webpage?

My JSF (webapp) pages are taking long time to load. 我的JSF(webapp)页面需要很长时间才能加载。 Tested through firebug, most of the time is spent waiting for response from server. 通过firebug测试,大部分时间都花在等待服务器的响应上。 So I think it's something on server that's eating up time. 所以我认为服务器上的东西正在耗费时间。 I have been trying to get some hints using Netbeans based profiler but while analyzing CPU performance, it just shows the time spent in each method since some point of time. 我一直在尝试使用基于Netbeans的分析器获得一些提示,但在分析CPU性能时,它只显示了从某个时间点开始在每种方法中花费的时间。 So I cannot figure out what's eating up time when I sent request for a page. 因此,当我发送页面请求时,我无法弄清楚正在消耗的时间。

Can you give some hints as to how I should be able to gain this information that which of methods are eating time while serving request ? 您能否提供一些提示,说明我应该如何获得这些信息,即哪些方法在提供请求时正在节省时间?

I think you should take a look at a Profiler tool , if you have a large system and want to have the job done in a professional way. 我认为你应该看看一个Profiler工具 ,如果你有一个庞大的系统,并希望以专业的方式完成工作。 Otherwise you will end up by tracing your own code with time elapsed methods before each call (lol) 否则,您将在每次调用之前使用经过时间的方法跟踪您自己的代码(lol)

I have used Borland OptimizeIt and it did great job, back in the days :) 我已经使用过Borland OptimizeIt,它做得很好,回到过去:)

Take a look at: 看一眼:

JProfiler JProfiler的

YourKit YourKit

Jvisualvm (Javas own) visualvm.java.net (which is used in Netbeans too) Jvisualvm (Java类本身) visualvm.java.net (在Netbeans中使用过)

If you use eclipse take a look at TPTP bundle 如果你使用eclipse看看TPTP包

OptimizeIt 的Optimizeit

Time being taken on server. 在服务器上花时间。 First I would check if this might mean that the network is inducing latency (You need to check how firebug measures this). 首先,我会检查这是否意味着网络正在诱导延迟(你需要检查一下firebug如何衡量这一点)。

If you confirm is not a network latency issue then the best path to take would be a profiler, depending on your platform and the size of your app you can make the best choice. 如果您确认不是网络延迟问题,那么最佳路径将是分析器,具体取决于您的平台和应用程序的大小,您可以做出最佳选择。

For example, I would go for jvisualvm if your application loads less than 65k classes, otherwise you might experience issues. 例如,如果您的应用程序加载的类别少于65k,我会选择jvisualvm,否则您可能会遇到问题。

Once you start jvisualvm you can attach it to your app process. 启动jvisualvm后,您可以将其附加到您的应用程序进程。 Once in there I would recommend you try sampling profiling first, it is less aggresive in resource consumption (Not sure how big or loaded is your scenario, instrumentation profiling might be too heavy to support). 一旦进入那里,我建议你首先尝试采样分析,它在资源消耗方面不那么具有攻击性(不确定你的场景有多大或多大,仪器分析可能太重而无法支持)。

You just need to attach jvisualvm to your process, go to Sampler and press the Start button, data will be collected after that point in time, so after you have activated the sampling you should trigger your request, maybe a few times so you can get a better feel on where the time is being spent. 您只需要将jvisualvm附加到您的过程,转到Sampler并按下Start按钮,将在该时间点之后收集数据,因此在您激活采样后,您应该触发您的请求,可能需要几次以便您可以获得更好地了解时间花在哪里。

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

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