JohanSJA
JohanSJA

Reputation: 705

How can I measure the performance of a Java program?

How can I trace a Java program performance? Example, how long each method takes? How many resources were used and so on? I need some info for me to work on optimizing my Java program.

Upvotes: 0

Views: 932

Answers (5)

Hendra Jaya
Hendra Jaya

Reputation: 1628

In optimizing, it's hard to tell what causes the slow performance. Usually a bad algorithm (complexity) causes it. Maybe you can start from the algorithm first before go into further detail tweak

Upvotes: 0

Mr Moose
Mr Moose

Reputation: 6344

As others previously mentioned, profilers are the go. A long time ago, I'd used http://www.yourkit.com/, and found it quite easy to use and informative.

If you are keen, you could investigate using AOP for method timing etc. Just search Google for AOP method timing for some ideas.

Upvotes: 2

LordDoskias
LordDoskias

Reputation: 3191

Making a good and robust benchmark in java is hard. Take a look at the following articles: http://www.ibm.com/developerworks/java/library/j-benchmark1/index.html http://www.ibm.com/developerworks/java/library/j-benchmark2/index.html

Upvotes: 0

oksayt
oksayt

Reputation: 4365

You can try a JVM profiling tool such as JProfiler.

Upvotes: 0

fixmycode
fixmycode

Reputation: 8506

You could try opening your project in Netbeans, from there you can use the Profiler tool and get performance data for methods, load times, etc. It's really easy to use and the data is very complete.

Netbeans Profiler

Upvotes: 0

Related Questions