Analysis and comparison of Java Profiling Tools used in Java learning

Source: Internet
Author: User
Tags jprofiler netbeans


In the development process of  Java  program, it is unavoidable to encounter memory usage, performance bottleneck and so on. java profiler  Tools Help developers locate these issues quickly and effectively, making them an important tool in the  Java  development process. At present, there are many kinds of  Java Profiler  tools on the market, this article will briefly introduce several common tools, and compare them from the aspects of function and performance, so as to help  Java  programmers to choose suitable   Java Profiler  tools. This paper is divided into three parts: the first part briefly introduces the principles of  Java Profiler  tools; the second part of the current common  Java Profiler  tool  TPTP,  CodePro Profiler, YourKit Java Profiler, JProfiler  a Brief introduction  The third part compares the above tools from different angles to help developers choose the right tool. Relative to static code analysis,,profiling  is a dynamic analysis method for studying program behavior by collecting information from the program runtime. The aim is to locate the part that the program needs to be optimized to improve the speed of the program or the efficiency of memory usage. There are three ways to collect program run-time Information: Event methods: For  java, you can use  JVMTI (jvm tools interface) api  to capture such as method calls, class loading, class unloading  , entering  /  leaving threads, and then analyzing program behavior based on these events. Statistical sampling Method (sampling):  The method calls the system interrupt at intervals, then collects the current call stack (call stack) information, records the functions appearing in the call stack, and the call structure of these functions. Based on this information, the function's call graph and the  CPU  usage information of each function are obtained.  Since the information of the call stack is obtained at intervals, it is not very precise, but because the method has less interference with the target program, the target program runs at almost no speed. Implant additional instruction Method (BCI):  The method inserts instruction code into the target program that will record the &NThe information required for bsp;profiling , including runtime, counter values, etc., gives a more accurate memory usage, function call relationship, and function  CPU  usage information. This method has a certain effect on the program execution speed, so the program execution time may be inaccurate.  However, this method has some advantages in the running trajectory of the statistical program.  The  methods used by  Java Profiler  tools currently on the market are usually any combination of the above three methods.  profiler  Tool Features Although there are many  Java Profiler  tools on the market, the basic functions are mostly similar, this section first introduces these basic functions. Telemetry (Telemetry): Telemetry is the simplest way to see the behavior of an application running.  Often, multiple views (view) display  CPU  usage, memory usage, thread status, 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 the  CPU  usage of the entire application, and some tools can also show the  CPU  usage of each thread in the application.  The memory telemetry  view is typically used to display the allocation and usage of heap memory and non-heap memory.  The garbage collection telemetry  view shows detailed information about the garbage collector in  JVM .  The threads telemetry  view is typically used to display information such as the number of threads currently running, the number of daemons.  The classes telemetry  view is typically used to show the number of classes already loaded and not loaded. Snapshot (snapshot): After the application is started, the,profiler  tool begins to collect various execution data, some of which are displayed directly in the telemetry view, while most of the data is stored internally until the user asks for a snapshot, and the statistics based on the saved data are   Show it.  Snapshots contain information about the execution of an application over a period of time, typically with two types of snapshot:cpu  snapshots and memory snapshots. cpu  snapshots primarily contain the invocation relationships and runtime of functions in the application, which can often be used in  CPU View in the snapshot view. Memory snapshots mainly include the allocation and usage of memory, all classes loaded, the object information that exists, and the reference relationship between objects.  This information can often be viewed in a memory snapshot view. The main purpose of cpu profiling:cpu profiling  is to count the function's invocation and execution time, or, more simply, to count the application's  CPU  usage.  There are usually two ways to display  CPU Profiling  results:cpu  telemetry and  CPU  snapshots. Memory  profiling: The primary purpose of memory  Profiling  is to detect possible memory leaks through statistical memory usage and to determine the direction to optimize memory usage. There are usually two ways to display memory  Profiling  results: Memory telemetry and Memory snapshot thread  profiling: Thread  Profiling  is primarily used to identify memory problems in multithreaded applications.   generally includes three areas of information: a thread's state change condition deadlock condition distribution of state during a thread's lifetime profiling  startup settings: similar to  eclipse   Run  and  Debug  startup settings, the start-up settings are also required for  Profiling , including:profiling  mode   (cpu profiling    or memory  profiling), information acquisition type (telemetry  ,  sampling statistics or  BCI )   and so on.  profiler preference  settings: Mainly used for  Profiler  filter (select the package that needs attention, class), Sampling interval time setting, etc.  java profiler  Tool Introduction This article will then introduce several common  Java Profiler  tools on the market today. TPTP TPTP (test and performance tools platform) is  eclipse  Official  Profiling  Tool plugin. tptp  provides features such as testing, tracking (trace), performance testing, and graphical interface performance analysis.  TPTP  is also a scalable development platform framework that you can extend and integrate into your own products. tptp  can be installed through  Eclipse update Manager  or installation package, after successful installation, the following buttons will be added to the  eclipse . A separate  perspective  for inspection  TPTP profiling  results will also be added to  eclipse , as shown in: Codepro  profiler codepro profiler  is a commercial  eclipse  plugin introduced by  instantiations , which can be  Eclipse update Manager  Install or unzip the package directly and save it in the specified directory in  eclipse . Similar to  TPTP , after successful installation, there is a special  perspective  for viewing  CodePro profiling  results added to   eclipse , as shown in: Yourkit profiler yourkit java profiler  is also a commercial software that supports operating systems including:windows,  linux, freebsd, mac os x, solaris  and  HP-UX; supported  IDE  includes: Eclipse,  JBuilder, JDeveloper, NetBeans  and  intellij idea. Successful installation and first boot  YourKit  Java profilerAfter  , a dialog box will pop up to let the user select  YourKit Java Profiler  to integrate into the  ide, and specify the  IDE  installation path, click " Install plugin "button and the integration is successful, the,eclipse  will appear in the user can start  profiling from  Eclipse , but   The results of profiling  need to be queried in  YourKit Java Profiler , as shown in: Jprofiler jprofiler  is by   ej-technologies  launched a commercial software, supported by the operating system:windows, linux, mac os x, freebsd,  solaris, aix  and  HP-UX; support  IDE  includes: Eclipse, netbeans, intellij idea,  JBuiler  and  jdeveloper. After the installation is successful and the first time you start  JProfiler , a settings screen will pop up, after completing the steps shown in the left column,eclipse  , the user can start  profiling from  Eclipse . Similar to  YourKit Java Profiler , Profiling The results of   need to be queried in  JProfiler , as shown in: java profiler  Tools comparison This section will compare the above tools in the following ways: with  eclipse   Integration TPTP: A  Eclipse  development-based plug-in that makes integration with  eclipse  very good. After the installation is successful, all the settings and controls for  TPTP  can be done in  eclipse , and ProFiThe results of ling  can also be queried in  eclipse . codepro profiler:  and  TPTP  Similar,codepro profiler  is also a  eclipse  development-based plug-in, so with The integration of  eclipse  is very good.  The user can complete all operations on  profiling  in  eclipse . yourkit java profiler: yourkit java profiler  can be said to be a relatively independent tool, after successful installation, users can directly in the   eclipse  start  YourKit Java Profiler  and configure the  profiling  option, but the user must be in  yourkit  Profiling preferrence  is configured in the  Java Profiler  tool, and the  profiling  information must be View in  YourKit Java Profiler .  Therefore, the integration with  Eclipse  is general. jprofiler: jprofiler  is also a relatively independent tool, after successful installation, users can start the  jprofiler directly in  eclipse , all other operations must go back to   In the jprofiler  tool.  Therefore, the integration of  Eclipse  is not good.  Telemetry type TPTP: The currently used  4.6.2  version only provides thread  telemetry.  codepro profiler:  A total of five types:cpu,  memory  ,  threads  ,  loaded classes and garbage collection. yourkit java profiler:  and  codepro profiler , there is a lack of load class monitoring.  jprofiler: , like  CodePro Profiler , has a total of five types of monitoring methods.  cpu  snapshots contain statistical data types tptp: cpu  snapshots contain statistics such as the composition of packages, which are refined to the methods contained in the classes and classes.  Method call Relationship: The method invocation information for each thread as the root node, for each node that appears in the tree that represents the method, lists the run time or percentage of elapsed time for the method, and the number of times the method was called.  Method is called: Lists the other methods that call a method directly, and the number of times the method was called and the associated run time.  Hotspot List: Contains the method, class, or package that is the top ten of the  CPU  occupancy time. codepro profiler: cpu  snapshots contain statistical data types: package composition, refinement to included classes, and methods in classes. The invocation relationship of the method. Represented by a tree structure, there are three types of objects represented by the root node: A method invocation relationship with each thread as the root node, a method invocation relationship with the entire thread as the root   node, and a method invocation relationship for the root node in each method.  For each node that appears in the tree that represents the method, the run time or percentage of elapsed time of the method is listed, as well as the number of objects generated by the method   and the memory size allocated for those objects. The called relationship of the method.  The relationship is represented by a tree structure, where the root node is a specified method, and the child nodes of each node are the callers of the parent node.  Hotspot list: Contains some of the methods that are used before the  CPU  elapsed time. yourkit java profiler:cpu  snapshots contain statistical data types similar to  CodePro Profiler ; Jprofiler: With   codepro profiler , a method call relationship with each method as the root node is missing. Therefore, when you want to see the invocation relationship with a method as the starting point, you need to look in the tree structure of the line Chengweigen.  In addition, the call   relationship of the method is not represented by the tree structure, but by the way of the graph, it is difficult to see a global diagram in a screen when the call relationship is more complex. The memory snapshot contains the statistical data type TPTP: Contains the memory allocations for the class instances, including the number of objects instantiated, and theThe amount of memory that itself occupies.  Memory snapshots that are,tptp  compared to other  Java Profiler  tools contain less statistical data types. codepro profiler:  contains statistics that have memory allocations for class instances, including the number of objects instantiated, and the  shallow  and  retained  sizes of those objects. (shallow size  is the size of the object itself that takes up memory, does not contain references to other objects;retained size  is the object's own  shallow size,  Plus the sum of  shallow size  that can be accessed directly or indirectly from the object, that is, the object can be recycled to the total memory after being  GC .  Maximum Object list: Contains some of the objects before the  retained  size row.  A list of objects that are likely to have a memory leak: The object that contains the potential for a memory leak, and the likelihood size.  Yourkit java profiler: There is a missing list of memory leak objects compared to  CodePro Profiler .  Jprofiler: A list of  retained size  statistics and memory leak objects is missing compared to  CodePro Profiler .  The source code positioning function, that is, when a class, member variable, or method is selected in a snapshot, the corresponding definition can be located in the source code.  TPTP: You can only navigate to a class and cannot navigate to a method or member variable in it.  codepro profiler:  has this feature, but can only navigate to classes and member variables, and cannot navigate to methods.  Yourkit java profiler: You can navigate to classes, member variables, and methods.  Jprofiler: Similar to  CodePro Profiler .  Snapshot operations, mainly from the capture of snapshots, snapshots of the save and snapshot comparison of these three aspects. TPTP: When the application starts, the user can choose to take the snapshot at the appropriate time, these snapshots are not automatically saved, so when  eclipse  is closed, the snapshot data disappears, but the user can &NThe bsp;export  way to save the required snapshots. codepro profiler:  when the application is started, the user can choose to take snapshot capture at the appropriate time; These snapshots are automatically saved in  Eclipse Workspace  A temporary space outside, when  eclipse  shuts down, these snapshots will disappear and the user can save the required snapshots in a  export  way;codepro profiler   The comparison of snapshots is also provided, provided that the types of the two snapshots must be the same (for example: both run in  sampling  or  BCI ). Yourkit java profiler: When the application starts, the user can choose to take the snapshot at the appropriate time, for the memory snapshot,yourkit java profiler  It also provides the ability to automatically get snapshots, which are automatically saved to a temporary folder after the,eclipse  is closed, the files do not disappear; the other,yourkit java profiler   Snapshot comparison features are also available.  Jprofiler: The tool will ask you to specify a directory to save the  snapshot.  Performance, in  sampling  mode, the performance of these tools is very different, here is the main comparison in the performance of  BCI  mode.  TPTP: The currently used  4.6.2  version does not have a  BCI  mode. Codepro profiler: When the program is relatively large, the use of  BCI  mode for  profiling  speed is relatively slow, in addition, in the acquisition of memory leak candidate, the speed is quite slow. (When the program code volume  5  Thousands of lines,  Profiling  needs  5  minutes with  CodePro Profiler , when obtaining memory leak candidate , it takes  20  minutes) the operating speed in yourkit java profiler:bci  mode is alsoOK. (When the program code volume is  5 , need  1  minutes) Jprofiler: The program speed is not felt affected. (When the program code is  5 , it takes half a minute) robustness, when  profiling  is used by a large  CodePro Profiler  contrast application,  A stack overflow error is prone to occur. Conclusion tptp  is an open source software based on  eclipse , and provides a relatively simple function, so it is suitable for  eclipse  development-based applications, and the application is relatively simple; Codepro  Profiler  offers a relatively rich range of capabilities and is well integrated with  eclipse , but needs to be improved in terms of performance, so it is suitable for applications based on  eclipse  development. And not high performance requirements of the situation;yourkit java profiler,jprofiler  and  Eclipse  integration are general, provide a richer function, and good performance, Therefore, it is suitable for the low requirement of  eclipse  integration and high performance requirement.





Analysis and comparison of Java Profiling Tools used in Java learning


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.