Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   How to find-out CPU load ? (http://www.velocityreviews.com/forums/t123928-how-to-find-out-cpu-load.html)

Meir 07-01-2003 03:23 PM

How to find-out CPU load ?
 
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

Mike 07-01-2003 03:46 PM

Re: How to find-out CPU load ?
 
In article <9a17d4be.0307010723.14f944f8@posting.google.com >, Meir wrote:
> 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. Balk 07-01-2003 08:21 PM

Re: How to find-out CPU load ?
 
> 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. Balk 07-01-2003 08:23 PM

Re: How to find-out CPU load ?
 
> > 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?


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




All times are GMT. The time now is 01:54 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.