HomeDigital EditionSys-Con RadioSearch Java Cd
Advanced Java AWT Book Reviews/Excerpts Client Server Corba Editorials Embedded Java Enterprise Java IDE's Industry Watch Integration Interviews Java Applet Java & Databases Java & Web Services Java Fundamentals Java Native Interface Java Servlets Java Beans J2ME Libraries .NET Object Orientation Observations/IMHO Product Reviews Scalability & Performance Security Server Side Source Code Straight Talking Swing Threads Using Java with others Wireless XML

Spaghetti code, sloppy algorithms, irrelevant code execution, dead code and so on can all lead to poor application performance. No matter how much planning goes into the design of an application, there always seem to be some gray areas where code performance runs slower than expected or doesn't execute at all. If you've ever encountered this, ever wondered how fast your application's functions and events are really executing, or if they are executing at all, then NuMega's DevPartner for Java is a set of tools you should definitely look into.

NuMega is best known for software and system debugging tools, such as SoftICE and BoundChecker. DevPartner for Java is a suite of tools that will help you analyze the performance of your application, discover where performance problems might be occurring and if the code was tested at all. It also offers feedback on your application's thread activity. This suite consists of three products: TrueTime, TrueCoverage and JCheck.

Earlier versions of the DevPartner for Java worked only with Microsoft's version of Java. At the time this article was written, you could use both the Java Virtual Machine (JVM) and the Microsoft Virtual Machine. For the JVM, DevPartner is compatible up to JDK 1.1.7a. As a bonus, both TrueTime and TrueCoverage aren't limited to analyzing applications written in Java; they can also analyze programs written in C++ and Visual Basic, as well as Java classes, DLLs and ActiveX components.

DevPartner comes on a CD and the installation is straightforward. NuMega uses InstallShield for the installation process, and there's a menu so you can choose which products you wish to install. By products, I'm referring to TrueTime, TrueCoverage, JCheck, the Microsoft Java Virtual Machine and Sun's Java Software Developers Kit 1.1.7a.

The Test of Time
TrueTime comes with an intuitive user interface, as illustrated in Figure 1. The Project Pane on the far left contains all the active files pertaining to TrueTime projects including all the Java classes that are used. The pane on the right is where all the timing information for the sessions is displayed. The figure shows there are two session windows open. The name of the program that was executed is displayed as part of the information on the session window's caption bar. If you ran a Java applet, it would contain the name of the applet viewer. The session window contains panes of its own. The left pane is for filter information and lists all the functions used by the tested application, as well as the "Top 20" functions. These are Source Functions, Functions, Called Sources Functions and Called Functions. In order to view the source functions, you need to have a copy of the program's source files.

Figure 1
Figure 1:

An examination of the information on the session windows shows each window with three tabs: Function List, Source (with the name of the source file) and Session Summary information. When examining the Function List, double-click on any of the listed functions and you will receive detailed information about the function in a Functions Detail dialog window. It details all the parent and child functions and methods the function uses, how many times it uses them and the average time the function was executed. The Source tab describes source code for each function you're examining, how many times the line of code was executed and the percentage of time TrueTime spent executing the line as well as any child functions it may have branched to.

Since TrueTime works with various JVMs, you can perform benchmark tests to determine if there are any coding inefficiencies with different VMs. Not every VM is created the same nor are they all equal. TrueTime's Session Summary is extremely useful to get all the Java classes, their function and the VM in one report.

Many developers have the latest and greatest computers; therefore, their applications seem to run at light speed on their systems compared with their clients' slower systems. This is where TrueTime really shines because it doesn't matter if you're using a Pentium II 450 MHz system or a Pentium 75 MHz system. All percentage calculations are based on the CPU cycle times of your processor; thus your results will be the same no matter what processor you run your tests on. This is very useful for establishing standardized benchmarks.

Covering the Spread
In many ways, TrueCoverage's interface is similar to its counterpart, TrueTime. It sports the same Explorer interface that many tools do nowadays. The left pane, the Project Pane, contains a tree-view of the elements that make up the active project. In the right pane, all the information relevant to TrueCoverage appears. An Output window provides feedback for what system resources, such as DLLs, are used and where in memory they are stored. Another window, a session window, also has the Explorer metaphor. The left pane is called the Filter pane and it provides a tree-view of files that make up the project being tested - EXEs, DLLs and Java classes. The right pane is called the Session Data pane. This pane is the heart of TrueCoverage's reporting. The top part of this pane has a progress bar that illustrates the number of lines and functions that have been executed during the testing phase. There are a number of tabs that help further back down session information, like a list of functions, view source code and a summary sheet that provides statistical information about the session report.

Just like TrueTime, TrueCoverage will also report on any executable or resource file used by the project, such as ActiveX Controls and DLLs. In addition, if you have source code for the project's components, it will provide feedback on this usage percentage and the number of lines executed. If you double-click on the Java class, the source code will be displayed in the Source code tab in the Session Data pane so you can see exactly what line of code was executed and how many times it was executed.

The true power of TrueCoverage is its ability to compare and merge multiple sessions with one another. Why is this important, you ask? Within an application's development cycle, developers need to be sure that when they make a change to a program, they test the functionality they just created, added or modified. The first time TrueCoverage is run and a test script is used against it, the generated report becomes the benchmark. As changes and enhancements are made to the application, test scripts must be modified and performed again. Each new report will cover which procedures were run, which ones weren't, how many times the functions, procedures and methods were used, and so on. You can then merge these results with previous reports to determine if the application is executing the correct logic. Unfortunately, it doesn't tell you in what order the functions or procedures were executed, which can be helpful in determining execution order. In event-driven programming, code doesn't always execute in the order you think it does.

Check, Please!
Now for something completely different, but extremely useful. At first glance JCheck might seem a bit awkward, but that's because most developers have never seen a thread model, even though they may understand threads. The folks over at NuMega obviously have, as illustrated in Figure 2, because the purpose of JCheck is to provide graphical representation of a Java class's thread activity. It also detects and displays events in the order they were executed, and detects and reports Java thread errors and thread leaks.

Figure 2
Figure 2:

The graphics representation of thread activities is displayed in a window called the Thread Inspector. It provides information about the Java class's state and interaction with Windows threads, synchronization objects, thread groups and other threads. This is very useful in determining problems with thread synchronization and timing issues, thread problems like deadlocks and thrashing, and run-time issues. To find out more about a thread object, simply place your mouse over the object and a pop-up window displays some basic properties about it.

Another window, called the Session window, is used for monitoring the method calls, class loads, thread states, context switches, synchronization objects and exceptions while you analyze your applet or application. The output of this is placed into two tabs - Results and Transcript. The Results tab is where detailed information about the source code's errors and leaks are reported. These are not errors that would be caught when an application is compiled. They are due to bad coding, like coding a "double-start," which occurs when you start a thread that was previously stopped. Not only does JCheck report these errors, it also attempts to offer solutions to fix the problem. Now it's not going to be able to offer solutions for every problem, but it does a good job solving most of the major threading problems.

The only major drawback I could find is that NuMega does not make a version of this suite for the Unix environment. However, many developers have multiple operating systems at their disposal, so this shouldn't be the real issue, nor should it stop you from considering this product.

The documentation is a sparse booklet that describes the functionality of each product. More information is contained in Adobe Acrobat PDF files, but don't expect to gain extensive knowledge from them. Don't let the limited documentation fool you, though. After about an hour with each product, I really felt I had mastered them and was able to get the information I was looking for. The fact that each product links the errors it finds to your source code is a major advantage and a big time-saver. For Visual J++ users, the fact that both TrueCoverage and JCheck have toolbar buttons for the Visual InterDev development interface is a nice touch.

With applications developed in components and distributed throughout the enterprise, the last thing you want is for your application to be the weak link in the chain. By using TrueTime, you can isolate areas of your program that are running more slowly than anticipated. You can also find out which functions are being called most often and determine if they are running as optimally as they should.

Like all the NuMega products, all three are solid, useful utilities. Whether you're developing 100% Pure Java programs or applications specific to the Microsoft VM, this tool is a must-have in any developer's toolbox.

About the Author
David Jung is an application developer specializing in client/server development using Visual Basic, Java and other Internet technology. He is also co-author of several Visual Basic books and can be reached at [email protected]


All Rights Reserved
Copyright ©  2004 SYS-CON Media, Inc.
  E-mail: [email protected]

Java and Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. SYS-CON Publications, Inc. is independent of Sun Microsystems, Inc.