The latest version of Eclipse (Eclipse 3.2) comes with Callisto, a rich set of optional plug-ins for Eclipse 3.2. Callisto includes a powerful analysis tool called the Eclipse Test and performance tools platform, referred to as TPTP. TPTP provides a comprehensive set of open source performance-testing and analysis tools, including integrated application monitoring, testing, tracking, and analysis, and static code analysis tools. The value of the analysis tool is incalculable for identifying and identifying performance issues in various Java applications. In this article, we'll explore how to use TPTP to ensure high quality and high performance code (even in unit and integration testing).
Install TPTP
The easiest way to install TPTP is to use the Remote update site (see Figure 1). Open the Remote Update window (Help-> Software Updates-> Find and Install), and then select Callisto Discovery Site. Eclipse will recommend installing the Callisto plug-in set. The TPTP tool is listed under "Testing and performance". The easiest and most time-consuming option is to install all of the recommended plug-ins. Even if you do not install the entire Callisto toolset, you will still need to install some other TPTP requirements, such as "Charting and Reporting", "Enabling Features", and "Data Tool performance".
Figure 1. Installing TPTP from a remote site
Profiling Java Applications
The test and performance tools platform is basically a set of analysis tools. Profiling an application usually involves observing how the application is handled under pressure. A common way to do this is to run a set of load tests on the deployed application and then use the Profiling tools to record the behavior of the application. The results can then be studied to investigate any performance problems. These things are usually done at the end of the project, because the application is almost ready to enter the production phase.
TPTP is perfect for this kind of task. A typical use case is to run a load test using a tool such as JMeter, and then use the TPTP induction tool to record and analyze performance statistics.
However, this is not the only way to use TPTP to analyze an application. In general, the earlier you test, the fewer problems you will encounter later. TPTP enables you to analyze code in many contexts, including junit test cases, Java applications, and Web applications. And it's well integrated into the Eclipse IDE. Therefore, there is no reason not to start preliminary performance testing and analysis at an early stage.
TPTP lets you test several aspects of your application's behavior, including memory usage (how many objects are created, how large the objects are), the execution of statistics (where the application spends more time), and test coverage (the exact number of code executed during the test). Each aspect can provide independent information about application performance.
In any case, a memory leak can and does exist in Java. Creating (and saving) unnecessary objects increases the need for memory and increases the workload of the garbage collector, which can compromise the performance of your application. Also, if the server running the application is running for a long time, the accumulated memory leaks may eventually cause the application to crash or the server will stop running. These are good reasons to be mindful of application memory leaks.
According to the 80-20 rule of thumb, 80% of the performance problems appear in 20% of the code. Or, in other words, if you focus on the most common part of your application, you can spend a relatively small amount of effort to improve the performance substantially. In this case, the execution of statistical data can be useful.
In addition, TPTP also provides some basic test coverage data. Although these statistics are not as complete as those provided by specialized tools such as Cobertura or clover, you can still quickly understand which methods performance tests are effectively testing.