• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Measure Java CPU usage

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
SivaramaKrishnan Nageswaran
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic