7

Is there any tool can measure execution time for each function call and find out bottle neck for a given developing java j2se project? Thanks!

Stan
  • 32,761
  • 45
  • 112
  • 170

7 Answers7

9

Use profiling tools, such as YourKit, JProfiler and HPROF (this one is a command line tool).

GreenGiant
  • 4,226
  • 1
  • 40
  • 69
b.roth
  • 8,919
  • 8
  • 33
  • 50
4

You are looking for a profiler. I know that NetBeans includes a decent one.

You can also look at this question: Open Source Java Profilers.

It seems that the JDK 1.6 comes with a basic profiler. So maybe you want to give it a try first.It should be included with the VisualVM that comes with your jdk6: visualvm profiler

Community
  • 1
  • 1
Janusz
  • 176,216
  • 111
  • 293
  • 365
1

Yes, there are lot of tools - profiles like Netbeans Profiler or eclipse equivalent. Look at this course of JavaPassion to find out more about profiling tools and performance of Java applications.

Look at also this SO question to find out open source java profiles.

Community
  • 1
  • 1
cetnar
  • 9,141
  • 2
  • 36
  • 44
1

Consider the most precise and non-intrusive async-profiler.

IntelliJ IDEA Ultimate has built-in profilers support: https://www.jetbrains.com/help/idea/cpu-profiler.html

Vadzim
  • 21,258
  • 10
  • 119
  • 142
0

You might try aspect oriented programming to intercept every method call and compute the duration.

fastcodejava
  • 35,219
  • 24
  • 124
  • 181
0

Measuring is fine, but is a very indirect way to find bottlenecks. A very direct way is this: just hit ctrl-break several times, and examine the thread stacks.

Any bottleneck will be a line of code, nearly always a function call, and it will appear often on the stack of some thread. The worse it is, the more often it will appear.

Just look for any such often-appearing line of code. If you can figure out how to call it less, or not at all, you will save a bundle of time, guaranteed. Here's why.

Community
  • 1
  • 1
Mike Dunlavey
  • 38,662
  • 12
  • 86
  • 126
0

Java JDK comes with JVisualVM under bin folder, once your application server (for example is running) you can run visualvm and connect it to your localhost, which will provide you memory allocation and enable you to perform heap dump

enter image description here

For more detailed steps on how to enable: http://sysdotoutdotprint.com/index.php/2017/08/01/turn-profiler-java/

mel3kings
  • 6,989
  • 3
  • 54
  • 60