Ever get the feeling you might be lost? Java can help you find your way back, at least in your programs. In the past, Java lacked the simple ability to map runtime code back to its position in the source code file. The pre-Java 1.4 solution was to manually parse an exception's stack trace. This tip shows how, with Java 1.4, you can trace that runtime code using Throwable's new getStackTrace() method. (1,500 words; March 8, 2002)
2. Use the JVM Profiler Interface for accurate timing
Most Java programs are multithreaded, either by design or because the garbage collector runs on its own thread. This makes performance analysis difficult because you can never be sure how much CPU time the thread scheduler actually allows a thread. Fortunately, Java 2's Java Virtual Machine Profiler Interface (JVMPI) provides the correct information on CPU time spent in the current thread accessed from within a Java program. (1,400 words)
Who doesn't have some performance problems in their Java applications? Let's be honest...all of us do. Code profilers are the only custom tools designed to tackle this universal problem. In this article, Laurence Vanhelsuwe reviews three commercial Java profilers: Borland's Optimizeit Suite, Quest Software's JProbe Suite, and ej-technologies' JProfiler. (4,000 words; August 22, 2003)
4. Profiling CPU usage from within a Java application