How to find-out CPU load ?

Discussion in 'Java' started by Meir, Jul 1, 2003.

  1. Meir

    Meir Guest

    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
     
    Meir, Jul 1, 2003
    #1
    1. Advertising

  2. Meir

    Mike Guest

    In article <>, 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
     
    Mike, Jul 1, 2003
    #2
    1. Advertising

  3. Meir

    S. Balk Guest

    > 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, Jul 1, 2003
    #3
  4. Meir

    S. Balk Guest

    > > 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
     
    S. Balk, Jul 1, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    721
  2. Guy Robinson

    win32print how to lower cpu load?

    Guy Robinson, Nov 30, 2003, in forum: Python
    Replies:
    2
    Views:
    554
    Mark Hammond
    Nov 30, 2003
  3. Just D.

    CPU Load

    Just D., Nov 21, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    399
    Just D.
    Nov 21, 2006
  4. KevinGPO
    Replies:
    2
    Views:
    348
    Jim Langston
    Jun 27, 2005
  5. pavunkumar

    How , system cpu and user cpu times calculates

    pavunkumar, Feb 27, 2009, in forum: C Programming
    Replies:
    1
    Views:
    359
Loading...

Share This Page