View previous topic :: View next topic |
Author |
Message |
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Tue Jul 30, 2002 5:30 pm Post subject: CPU Usage in Loops (and some STATUS info)... |
|
|
Thought this was kinda important...
CPU Usage
If you use a continous loop without a WAIT, CPU
usage goes to 100%.
Even a tiny WAIT ".01" drops CPU usage to almost
nothing. Check CPU usage while running this example.
STATUS Element
The help file states that only one STATUS element
may be added to dialogs. This is NOT correct.
I included multiple STATUS elements in the example
(notice that they're added from the bottom up).
Tested with Sysmon.exe (to check CPU usage),
VDS 3.5, and Windows 95.
______________________________________________________________________________________________
Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Test CPU Usage",-1,0,200,90
DIALOG ADD,BUTTON,Wait,5,5,60,20
DIALOG ADD,BUTTON,NoWait,5,70,60,20
DIALOG ADD,BUTTON,Stop,5,135,60,20
DIALOG ADD,STATUS,Stat1
DIALOG ADD,STATUS,Stat2
DIALOG ADD,STATUS,Stat3
DIALOG SHOW
:StopBUTTON
:EVLOOP
DIALOG SET, Stat1, "Stat1 - Ready..."
DIALOG SET, Stat2, "Stat2 - Ready..."
DIALOG SET, Stat3, "Stat3 - Loop not running..."
WAIT EVENT
goto @event()
:WaitBUTTON
DIALOG SET, Stat1, "Stat1 - Loop running using WAIT "@chr(34).01@chr(34)
DIALOG SET, Stat2, "Stat2 - Ready..."
DIALOG SET, Stat3, "Stat3 - Ready..."
REPEAT
WAIT ".01"
%e = @event()
UNTIL %e
goto %e
:NoWaitBUTTON
DIALOG SET, Stat1, "Stat1 - Ready..."
DIALOG SET, Stat2, "Stat2 - Loop running without WAIT"
DIALOG SET, Stat3, "Stat3 - Ready..."
REPEAT
%e = @event()
UNTIL %e
goto %e
:CLOSE
EXIT
|
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
Dr. Dread Professional Member
Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Jul 30, 2002 8:28 pm Post subject: Re: CPU Usage in Loops (and some STATUS info)... |
|
|
Mac wrote: | Thought this was kinda important...
CPU Usage
If you use a continous loop without a WAIT, CPU
usage goes to 100%.
Even a tiny WAIT ".01" drops CPU usage to almost
nothing. |
Hey Mac
Yeah, this is really important. I noticed it some months ago, and now I have WAIT commands
of various length in all my :evloop sections etc. It just did not cross my mind to put this info on
the board
Mac wrote: |
STATUS Element
The help file states that only one STATUS element
may be added to dialogs. This is NOT correct.
I included multiple STATUS elements in the example
|
Ahaa, this might come in handy. And yet another time this shows ya that one shouldn't always
just rely that the documentation is 100% correct - often playing around with things may bring
about interesting stuff.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
Back to top |
|
|
moke Contributor
Joined: 02 Jan 2002 Posts: 162
|
Posted: Wed Jul 31, 2002 1:13 pm Post subject: |
|
|
Hi Mac,
I ran into this (CPU usage) a while back and ended up with the same conclusion.
Unfortunately, I didn't notice until NT/2000 users started
complaining . It is certainly a good piece of information.
I didn't know about the multiple status elements, pretty cool. Thanks!
moke |
|
Back to top |
|
|
Skit3000 Admin Team
Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Jul 31, 2002 1:26 pm Post subject: |
|
|
You can even have a status-bar on top of the window!!!
If that isn't strange...
Code: |
DIALOG CREATE,New Dialog,-1,0,240,160
DIALOG ADD,STATUS,STATUS1,STATUS1
DIALOG ADD,BUTTON,BUTTON1,102,56,,,BUTTON1
DIALOG SHOW
:evloop
wait event
goto @event()
:button1button
dialog hide,status1
dialog show,status1
window position,New Dialog,,,240,160
goto evloop
:Close
exit
|
Looks like an gray EDITBOX... |
|
Back to top |
|
|
FreezingFire Admin Team
Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Jul 31, 2002 1:58 pm Post subject: |
|
|
You can put progress bars in the status elements like in an example of a tree-list that Mac made...but I can't remember where it is... _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
Back to top |
|
|
Mac Professional Member
Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Wed Jul 31, 2002 10:34 pm Post subject: |
|
|
Most VDS elements in the same location are "stacked" as they
are added - just add the progress bar (DIALOG ADD) after the
status bar.
If an element won't show on top of another one, try adding a
group (same size as the top element), then put the top element
in the group.
Cheers, Mac _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|