How to measure performance in Java developement

前端 未结 7 1301
温柔的废话
温柔的废话 2020-12-10 16:13

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!

相关标签:
7条回答
  • 2020-12-10 16:35

    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

    0 讨论(0)
  • 2020-12-10 16:42

    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

    0 讨论(0)
  • 2020-12-10 16:42

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

    0 讨论(0)
  • 2020-12-10 16:45

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

    0 讨论(0)
  • 2020-12-10 16:49

    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.

    0 讨论(0)
  • 2020-12-10 16:54

    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

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

    0 讨论(0)
提交回复
热议问题