什么是概要分析,如何配置我的Java程序? [英] What is profiling all about and how can I profile my Java program?

查看:138
本文介绍了什么是概要分析,如何配置我的Java程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说过很多关于分析的内容。这是怎么回事?据我所知,这是一种表现测量,但有人可以更清楚地阐述这一点,以便新手可以掌握这个想法。此外,我使用Eclipse IDE为我的Java程序。我可以使用Eclipse IDE配置我的程序吗?分析时考虑的因素是什么(我的意思是最佳实践)?

解决方案

代码行被执行,花费了多少时间(与其他行相比)。这很容易找出您的代码大部分时间所在的位置。



它还可以找到您的代码花费很多时间而不做任何事情的地方:这是缓存未命中的典型迹象,这是您应该积极参与的地方。 / p>

通常,程序在一个地方花费很多时间(比如90%)。不幸的是,找不到这个地方没有分析是不可能的。猜猜经常走错了。所以如果你在错误的地方进行优化,那根本就不会有帮助:如果在这一行上花费的总时间只有10%,你的代码只能快10%(最好!)。但是,如果您成功地删除了90%的时间内的电话,您的程序将会快速获得10倍的。



简单来说,是剖析。



Eclipse提供了内置的分析能力,我被告知他们很好,但是由于我不认识他们,让某人否则回答。


I've heard a lot about profiling. What is this all about? As far as I understand this is some kind of performance measurement but can someone elaborate this on more clearly so that a newbie can grasp the idea. Also, I use Eclipse IDE for my Java program. Can I profile my program using Eclipse IDE? What are the factors to be considered while profiling (I mean the best practices)?

解决方案

Profiling basically shows you how often a given line of code is executed and how much time was spent in it (compared to other lines). This makes it easy to pinpoint the location where your code spends most of the time.

It also makes it possible to find places where your code spends much time without doing anything: this is the typical sign of a cache miss and this is where you should get active.

Usually, programs spend very much time (say, 90%) in one place. Unfortunately, finding this place without profiling isn't possible. Guesswork often goes awry. So if you optimize in the wrong place, this won't help at all: if the overall time spent in that line is only 10%, your code will only get 10% faster (at best!). If, however, you succeed in removing the call that takes 90% of the time, your programm will get ten times faster.

This, in a nutshell, is profiling.

Eclipse offers builtin profiling capabilies and I've been told that they're pretty good but since I don't know them, let someone else answer that.

这篇关于什么是概要分析,如何配置我的Java程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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