wood burning stoves 2.0*
The moose likes Performance and the fly likes Measure Java CPU usage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Measure Java CPU usage" Watch "Measure Java CPU usage" New topic
Author

Measure Java CPU usage

SivaramaKrishnan Nageswaran
Greenhorn

Joined: Aug 05, 2005
Posts: 7
Hi,

I'm not sure whether this is the right forum to post this message.

I have a java application and basically it takes lots of CPU time and memory. What my concern right now is the CPU usage. Basically I reduced the number of CPUs from 8 to 4 (Solaris v1280 box) and the CPU usage got increased from 30% to 90%

My requirement: Is there anyway that I can measure the CPU usage using Java code itself, so that I can insert those "set of APIs" (for measuring CPU usage), between APIs to collect the CPU usage data?

Thanks,
Siva
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Welcome to the Javaranch. You can monitor a JVM using the management api (JMX). However, that will just tell you what you already know: Your program uses a lot of CPU. What you want is a code profiler like JProfiler or JProbe. They will help you determine where the bottlenecks are in your code and benchmark alternate implementations.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
SivaramaKrishnan Nageswaran
Greenhorn

Joined: Aug 05, 2005
Posts: 7
Does JDK 1.3.1 have support for JMX ? And is that also possible to measure the CPU usage of every thread using JProbe? Because so far (as far as I know), Jprobe gives the memory usage and hasn't seen the CPU usage. Can you also tell the procedure for getting the CPU usage using JProbe?

Thanks
Siva
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

Originally posted by SivaramaKrishnan Nageswaran:
Does JDK 1.3.1 have support for JMX ?

Not that I know of.

Jprobe gives the memory usage and hasn't seen the CPU usage. Can you also tell the procedure for getting the CPU usage using JProbe?

You must be looking at the Memory Debugger. There's another product called the Profiler which is used to identify bottlenecks. There's tutorials provided with JProbe which will teach you how to use it. Profiling is not as easy as hitting a button and getting a report. You need to learn how to use the tools effectively so you can figure out what changes will do the most good.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Measure Java CPU usage
 
Similar Threads
Calculation of CPU load
How to get thread id?
CPU usage and memory usage by processes
Applet uses 100% CPU
CPU usage