Alexandru
Alexandru

Reputation: 25840

How to measure performance of a Java application?

I have a CPU intensive multi-threaded Java application and I'm looking for ways to measure its performance at run time (useful for automation). I tried a few options

System.currentTimeMillis();
System.nanoTime();
ThreadMXBean.getThreadCPUTime();

The first two measure real time. The last measures CPU time for only one thread. I want to measure the CPU-time for all threads spawned by the process.

Before resurrecting an old machine and dedicate it for this task, I would like to see what options I have now.

I run Linux and a platform dependent solution is acceptable, but least desirable.

Upvotes: 11

Views: 3509

Answers (2)

gaurav
gaurav

Reputation: 169

Try to enable the JVM with Dtrace. It has a lot of performance probes which help you get what ever you want.

Upvotes: 2

Eran Harel
Eran Harel

Reputation: 2365

Try perf4j: http://perf4j.codehaus.org/ I recommend using it along with AOP, but it's not a must. See http://perf4j.codehaus.org/devguide.html#Using_Spring_AOP_to_Integrate_Timing_Aspects for more details on AOP.

Upvotes: 11

Related Questions