Use open-source Profiler to test the performance of your Java application

Source: Internet
Author: User

Recently, some friends talked about system performance analysis. The best way to analyze why a Java-based system is slow is to use profiler.

The principle of profiler is to use some drivers and JVM bindings to read the JVM runtime and get the time from loading the class to the execution to the end of the entire process, so as to know the methods of those functions make your system slow.

Good open-source profiler tools include extensible Java profiler and eclipse profiler plugin.

1 extensible Java profiler is generally used to test desktop applications.

Run a program using the following methods:

Run-enabled application-Main-class
Java-xruntracer application-Main-class

The program will later upload a tracer-output.bin.gz

Use ejp presenter to open the generated file. By selecting the classes you are interested in, you can view the call time of each method during execution.

2 eclipse profiler plugin is usually used to test webapplication

Take Tomcat as an example. Add the following configuration to Catalina. BAT:

Set _ execjava = % _ runjava %
Set mainclass = org. Apache. Catalina. startup. Bootstrap
Set action = start
Set security_policy_file =
Set debug_opts =
Set JPDA =
Following line:
Set java_opts =-xrunprofilerdll: 1-xbootclasspath/A: jakarta-regexp.jar; profiler_trace.jar; commons-lang.jar-d1_profiler_package_filter =__ A __% mainclass % ;__ M _ sun .; __m _ COM. sun .; __m _ java .; __m _ javax .; __m _ Org. apache. -d1_profiler_timing_method = 1

_ A _ indicates the startup class _ M _ indicates the class not monitored.

Go to eclipse, set the class to be monitored in profiler of the run panel, and start Tomcat. The running result can be seen in the following panel. Including the execution time and call rate.

When you encounter performance bottlenecks, you may want to test it by yourself. You may find many problems. Code Refactoring can help

Additional points

1 If the presenter of extensible Java profiler reports an error when running: the class version is 4.9, it should be 4.8, because the jdk1.5 compiled class is 4.9, and jdk1.4 is 4.8, therefore, you can install another JDK 1.5 and set the JRE path to run it.

2. It is normal that the speed will slow down during running. Therefore, when looking at the results, you cannot just look at the execution time, but the percentage.

3. The generated ejp file will be large and can be cleared in time after running.

4. Eclipse profiler plugin cannot install plug-ins in the new version. I don't know why, but there may be some compatibility issues. I have been using eclipse 2. x all the time.

Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 469720

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.