How to find-out CPU load ?

M

Meir

Is there a way in Java to find-out the current CPU load ?

Are there any external packages for this ?

All I need is a single number in percents,
but I need a solution for Windows2K and UNIX.

Meir
 
M

Mike

Is there a way in Java to find-out the current CPU load ?

Are there any external packages for this ?

All I need is a single number in percents,
but I need a solution for Windows2K and UNIX.

Meir

First you must get the system paramter to find out what system you're on.
For each type of system load the right module: the kernel32.dll for
windows and nothing for unix/linux. I'm sure there is a call you could
make with the kernel32.dll to find the windows load average. For unix
exec /usr/bin/uptime and read/parse its output. For Linux you can
open and read /proc/cpuinfo until you find the load average.

Mike
 
S

S. Balk

You could do it the same way Windows itself does run a task at the
lowest priority and see how many cycles it manages to consume.

This would stress the CPU to 100%

What's the timespan for this counting (every second) to prevent it from
stressing the cpu to much?
 
S

S. Balk

You could do it the same way Windows itself does run a task at the
This would stress the CPU to 100%

What's the timespan for this counting (every second) to prevent it from
stressing the cpu to much?

Another point, this won't give you a percentage, because you don't know how
much cycles you get when the cpu is *totally* idle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top