[DUG] CPU usage

Jolyon Smith jsmith at deltics.co.nz
Thu Aug 20 16:22:39 NZST 2009


Whatever you use is a bit meaningless imho.

100% CPU utilisation (in a single CPU system) simply means that there is
some process (or processes) running that is not specifically giving up time
slice or which is/are not waiting on other resources such as IO etc.

In theory it could be a single CPU-bound process "consuming" all available
CPU time, but it is only able to do so because no other process is demanding
a share of that available time.

Any CPU bound process will appear to consume ALL available CPU time, because
in the absence of any other demand on CPU time, that is what it will get,
whether it strictly speaking "needs" it or not.

So whether such a process is "important" or not is an entirely different
question, and whether adding another CPU-bound process to the system will
result in "overload" is by no means certain.

And I don't think there is any reliable way to determine that.

To get a meaningful idea of system "load" you would probably need to take
into account a whole host of other factors... overall system memory use,
virtual memory paging statistics etc etc.


All of which is possible using system performance counters, but ultimately
still not entirely reliable and depending on why you are doing it, quite
possibly not worth the trouble (and you may run the risk that your algorithm
never finds a "quiet enough" time to allow your process to get going).


-----Original Message-----
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] On
Behalf Of John Bird
Sent: Thursday, 20 August 2009 15:59
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] CPU usage

Is there a simple way to find simple measure of current CPU usage?

Reason - have some housekeeping tasks that I would prefer to not run if the
computer is loaded at the moment, so an easy way to check before starting it
would be great.

Does not have to be too precise for my case, basically something that
answers "is the computer really busy or mainly idle at the moment?"

Here is a couple of examples I found -  wondering if there is a simpler call
for XP/Vista/Windows 7
http://www.swissdelphicenter.ch/torry/showcode.php?id=969
http://www.vbforums.com/showthread.php?t=343530

John


_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe




More information about the Delphi mailing list