| View previous topic :: View next topic |
| Author |
Message |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Tue May 14, 2002 12:20 pm Post subject: CPU Useage |
|
|
How can I find the CPU Useage in all windows 32 bit platforms? I would
prefer to not use a dll but if needed, I will. Also, if the dll is freeware
that would be even better. Thanks. _________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue May 14, 2002 1:09 pm Post subject: |
|
|
Hi, Chris!
That one is a problem. I tried to do this myself - in Win9x/ME it is no problem because
the CPU usage can be read in the registry, but I'm sure that you know that already.
But the NT based Win family does not have this registry entry so it's impossible to
obtain CPU usage directly from VDS. As you mention - it will take a DLL, but I'm afraid
that it does not exist as yet (I have not seen this function in any of the DLLs that I've
looked into).
So on the bottom line: I had to give up when I tried a couple of months back, but if you
succeed, I sure would like to know.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
marty Professional Member


Joined: 10 May 2001 Posts: 789
|
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Tue May 14, 2002 4:15 pm Post subject: |
|
|
Yes. I do know how in 98 and 95. But, I haven't
found a way in NT, 2k and XP.
I hope someone can use Martins links and make
a dll for it.
Thanks Dr. Dread and Martin. _________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Thu May 16, 2002 12:40 am Post subject: |
|
|
You can use the following DLL:
http://www.vdsworld.com/files/vdscpu.zip
Thanks to Alexey A. Dynnikov for the CPU Usage component (and to Marty
for referring to this component).
The DLL is free as it is. Please notice that it'll become shareware once it
becomes part of the VDSDLL.
Commands:
CPU COLLECT
For reading the CPU data. The statistics won't become updated until you
do this.
Functions:
@CPU(COUNT)
Returns the number of CPUs. Please note that this returns one more than
the actual number of CPUs on Windows 2000 (NT?).
@CPU(WINNT)
Returns 1 if running on Windows NT platform.
@CPU(USAGE,<cpu number>)
<cpu number> is zero based. The returned number is a percentage
divided by 100, so that a value of 0,101 would mean 10,1%. Note that
somehow this value sometimes is negative. In the example script I just
have it assume a value of zero percent in that case.
Have fun with it!
Tommy |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Thu May 16, 2002 2:20 am Post subject: |
|
|
Great! Thanks a lot Tommy!!  _________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Thu May 16, 2002 10:56 am Post subject: |
|
|
Tommy,
I tried the VDSCpu.dll and the script you included did not work.
I get an error at line 27
| Code: |
%u = @cpu(USAGE,@pred(%i))
|
Error on external command or function.
I was messing with it for a little, and if %i is anything higher than 0
I get the error. And if I use 0 the script crashes..Humm
Any ideas? _________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Thu May 16, 2002 11:50 am Post subject: |
|
|
| LiquidCode wrote: |
I tried the VDSCpu.dll and the script you included did not work.
I get an error at line 27
I was messing with it for a little, and if %i is anything higher than 0
I get the error. And if I use 0 the script crashes..Humm
Any ideas? |
You might try to replace the bRenewbutton routine with this:
| Code: |
:bRenewbutton
list clear,lCPUUsage
cpu collect
%%CPUcount = @cpu(count)
if @equal(@cpu(winnt),1)
%%CPUcount = @pred(%%CPUcount)
end
if @not(@greater(%c,1))
%%text = %%CPUcount CPU
else
%%text = %%CPUcount CPUs
end
list add,lCPUUsage,%%text
%%increment = 0
repeat
%%usage = @cpu(usage,%%increment)
%%increment = @succ(%%increment)
if @greater(0,%%usage)
%%usage = 0
end
list add,lCPUUsage,%%increment @fmul(%%usage,100) %
until @equal(%%increment,%%CPUcount)
goto evloop
|
By the way, the DLL seems OK in Win9x but on my W2K machine I get strange readings; output values toggle between 0 and a fixed value (44%) as far as I remember. Did not try it on my XP yet.
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Thu May 16, 2002 12:28 pm Post subject: |
|
|
Oops... Thanks... I missed that. _________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Fri May 17, 2002 12:36 am Post subject: |
|
|
Checked this DLL out on my XP system now. Some feedback:
1. @cpu(winnt) returns 0, so the DLL does not recognize XP as being NT-based.
2. @cpu(count) still returns one processor too many, though (just like other NT versions).
Apart from that it checks out OK.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Sat May 18, 2002 5:43 am Post subject: |
|
|
Here's a new version:
http://www.vdsworld.com/files/vdscpu.zip
Hopefully it'll work better now, although I doubt it would fix the mentioned
0%/44% problem on Windows 2000. The @CPU(WINNT) function has been
changed to return either WIN32, WIN32S or WIN32NT, which is consistent
to the values returned by the VDSUTIL DLL.
Also a CPU DECIMALSEP,<new decimal separator> command has been added.
You should set this to the same value as set with OPTION DECIMALSEP in
VDS. Doing this may fix a bug in Chris' PCView program causing it not to work
for me.
Tommy |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Sat May 18, 2002 12:42 pm Post subject: |
|
|
Thanks Tommy. I'll give the new one a try. _________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
|
| Back to top |
|
 |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sat May 18, 2002 5:24 pm Post subject: |
|
|
Works fine on WinME.
-Garrett |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Sat May 18, 2002 6:35 pm Post subject: |
|
|
Works fine on 98SE also. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
|