0

There are many tools for code quality. But sometimes need gain performance also if code is not corresponds to rules of cod quality. Exists some open source tool for this? Thanks.

user710818
  • 23,228
  • 58
  • 149
  • 207
  • You may want to expand on this question some. Give a brief explanation of the application you are trying to profile. as an example, if your application is IO heavy the performance gains may not come from the code. This is a very broad topic. If you provide more details in your questions, you may receive tips on how others have achieved success in performance tuning. – Sean Nov 02 '11 at 19:02

3 Answers3

2

There's no tool for that, but you can try out jVisualVM, however.

http://download.oracle.com/javase/6/docs/technotes/tools/share/jvisualvm.html

It usually comes with your jdk. @ C:\Program Files\Java\jdk1.6.0_21\bin

Mob
  • 10,958
  • 6
  • 41
  • 58
  • I love Visual VM, but it tells you nothing about how your code affects performance or rules of "cod" [sic] quality. It will show you memory, CPU, etc. but it won't tell you what to do if your measures are sub-optimal. I'd recommend getting version 1.3.2, with all the plugins installed, rather than the one that's bundled with the JVM. – duffymo Nov 02 '11 at 20:26
0

No tool is going to tell you performance and quality. Both are hard to measure.

You can certainly use something like FindBugs or IntelliJ's Inspector to examine your code, but they'll just look for rule violations. I'm not aware of a tool that will point out when I've written code that performs badly. How will a Java code inspector know that your database has no indexes?

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • 1
    You have red question bad or you don't know subject. My advice please read some books about tuning java performance and you will find many tips about. Also e.g. PMD produce some performance tips. – user810430 Nov 02 '11 at 18:35
  • It may/not be hard to measure performance, [but it's not hard to improve it](http://stackoverflow.com/questions/266373/one-could-use-a-profiler-but-why-not-just-halt-the-program/317160#317160). – Mike Dunlavey Nov 03 '11 at 20:44
  • And this has what do to with open source tools to help? Your point is correct; I think the question is poor. – duffymo Nov 03 '11 at 21:23
  • All you need is an open-source debugger (that you can interrupt) :) I suppose one could claim that's not answering the question, read narrowly. – Mike Dunlavey Nov 05 '11 at 15:17
0

I can't answer you regarding code quality. Others can. But when you "need gain performance", I would rather tell you how to do it than tell you what tools to use.

There are tools, but more important than tools is understanding what you're doing. The most important is to understand that measuring doesn't tell you what to fix to get higher performance; it only tells you how much improvement you got.

The way to improve performance is to find activities, whatever they are, that account for a significant fraction of time and can be improved. Measuring is not finding. Example:

I can manually sample the state of a program, several times, and see it much of the time doing container class manipulations, like fetching elements, testing for end conditions, etc. (That's the finding part.) This can be happening in many different places in the code, so no particular routine appears to be causing a large fraction of time to be spent. There is no particular hotspot or obvious bottleneck. There is no "bad algorithm" or "slow routine", the kinds of thing people say they look for. Nevertheless, I can see in those few samples that it is doing container class operations, and I can see exactly where. If I can replace those container class operations with something else that accomplishes the same purpose, I can save time. How much time? Up to roughly the fraction of time I saw those operations happening, and that can be quite large.

The real payoff for doing this is there can be multiple issues. Suppose issue A costs 40% of the time, B costs 20%, and C costs 10%, and the total time is, say, 10 seconds. You go after A, the most obvious one. Fixing it reduces time to about 6 seconds. (Speedup 10/6 = 1.67). Then problem B takes a larger percent of time (2/6 = .33) so it is easier to find with samples. Fixing it reduces time to 4 seconds (Speedup 6/4 = 1.5) Then C is (1/4 = 25%) and is much easier to find than before. Removing it reduces time to 3 seconds (Speedup 4/3 = 1.33). The total speedup factor is 10/3 = 3.33. You can look at it as the compounded product of each speedup: 10/6 * 6/4 * 4/3 = 10/3.

Now I'm dealing in numbers here, but none of these had to be measurements of time spent in localized pieces of code. They were just rough estimates gotten from describing what was happening in a small number of detailed samples of what the program was doing. The samples aren't really concerned with measuring. They are concerned with exposing the problems.

Community
  • 1
  • 1
Mike Dunlavey
  • 40,059
  • 14
  • 91
  • 135