Analysis and comparison of common Java Profiling Tools

Source: Internet
Author: User
Tags comparison garbage collection memory usage cpu usage

In the process of developing Java programs, it is unavoidable to encounter problems such as memory usage, performance bottleneck and so on. The Java Profiler Tool helps developers locate these issues quickly and efficiently, making it an important tool in the Java development process. At present, there are a variety of Java Profiler tools in the market, this article will briefly introduce several kinds of tools that are common at present, and compare them from the aspects of function and performance, so as to help Java programmers choose the appropriate Java Profiler tools.

This article is divided into three parts: the first part briefly introduces the principle of Java Profiler tool; the second part of the current common Java Profiler Tools TPTP, Codepro Profiler, Yourkit java Profiler, Jprofil The third part compares the above tools from different angles and helps the developers to choose the right tools.

Compared with static code analysis, Profiling is a dynamic analysis method to study program behavior by collecting the information of program running. The goal is to locate the part of the program that needs to be optimized, thereby increasing the speed of the program or the efficiency of memory usage. There are three main ways to collect program Run-time information:

Event methods: For Java, you can use the JVMTI (JVM Tools Interface) API to capture events such as method invocations, class loading, class unload, enter/leave threads, and then analyze program behavior based on these events.

Statistical sampling Method (sampling): This method calls the system interrupt at intervals, then collects the current call stack information, logs the functions appearing in the call stack and the call structure of these functions, based on which the function's call graph and CPU usage information for each function are collected. Because the information of the call stack is acquired at intervals, it is not very precise, but because the method has less interference with the target program, the running speed of the target program is almost unaffected.

Implanted additional instruction Method (BCI): This method inserts instruction code into the target program, which records the information required by the profiling, including the running time, counter value, and so on, giving a more accurate memory usage, function call relationship and CPU usage information of the function. This method has a certain effect on the speed of program execution, so the program execution time given may not be accurate. But the method has some advantages in the running track of the statistic program.

The information collection method used by the Java Profiler tools in the market is usually any combination of the above three methods.

Introduction to Profiler tool function

Although there are many Java Profiler tools on the market, but the basic functionality is mostly similar, this section first introduces these basic features.

Telemetry (Telemetry): Telemetry is one of the easiest ways to view the behavior of an application. There are often multiple views (view) that display CPU usage, memory usage, thread state, and other useful information in real time, so that users can quickly discover the key to the problem.

The CPU telemetry view is typically used to show CPU usage across the entire application, and some tools can also display CPU usage for each thread in the application.

The Memory telemetry view is typically used to show the allocation and usage of heap memory and non heap memory.

The garbage Collection Telemetry view shows the details of the garbage collector in the JVM.

Threads Telemetry view is typically used to display information such as the number of currently running threads, the number of daemons, and so on.

The Classes telemetry view is typically used to display the number of classes that have been loaded and have not yet been loaded.

Snapshot (snapshot): After the application is started, the profiler tool starts to collect various execution data, some of which are shown directly in the telemetry view, and most of the data is kept internally until the user asks for a snapshot and the statistics based on the saved data are displayed. Snapshots contain information about the execution of an application over time, usually with two types of snapshots: CPU snapshots and memory snapshots.

CPU snapshots consist primarily of invocation relationships and run-time times of functions in an application, which can often be viewed in the CPU snapshot view.

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.