wscript.sleep 1 and wscript.sleep 2 
Author Message
 wscript.sleep 1 and wscript.sleep 2

I'm meeting strange phenomenon.

do until condition
do something
wscript.sleep 1
loop

The loop takes 10 to 20 minutes, and about 50,000 iterations. If I don't
place /wscript.sleep/, CPU usage is 99-100%. If I do /wscript.sleep 1/, the
usage is 7-10%. Funny is that if I do /wscript.sleep 2/, the usage is always
37-40%. I tested again and again, but the result is always same. Other than
CPU usage, the performance is same with/without /wscript.sleep/. If I apply
2 instead of 1, the performance is a bit degraded as expected. What I'm
curous is CPU part. What happened in /2/ instead of /1/. Is /1/ magic number
or something?

--
Have a nice day.
Han Pohwan, Microsoft MVP, Korea



Sat, 04 Jun 2005 16:51:40 GMT  
 wscript.sleep 1 and wscript.sleep 2

Quote:

> I'm meeting strange phenomenon.

> do until condition
> do something
> wscript.sleep 1
> loop

> The loop takes 10 to 20 minutes, and about 50,000 iterations. If I
> don't place /wscript.sleep/, CPU usage is 99-100%. If I do
> /wscript.sleep 1/, the usage is 7-10%. Funny is that if I do
> /wscript.sleep 2/, the usage is always 37-40%. I tested again and
> again, but the result is always same. Other than CPU usage, the
> performance is same with/without /wscript.sleep/. If I apply 2
> instead of 1, the performance is a bit degraded as expected. What I'm
> curous is CPU part. What happened in /2/ instead of /1/. Is /1/ magic
> number or something?

Here's a rather simplistic test case. Using different values for msecSleep,
I didn't see any appreciable difference in overall CPU usage as observered
using TaskManager.  The only real effect I could see, is the expected
reduced number of iterations through the time limited loop as the msecSleep
value increased.

An interesting observation was that on a W2K Pro sp2 box with WSH 5.6,
incrementing msecSleep by 10 affects the number of iterations within the 10
second max, but increments by 1 do not.

msecSleep = 10 'milliseconds to sleep per iteration
secDelay = 10 'max seconds for loop to execute
t1 = timer

for n = 1 to 1000000
  wscript.sleep msecSleep
  e1 = timer() - t1
  if e1 > secDelay then i = n : exit for
next
wscript.echo i,  e1

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Sun, 05 Jun 2005 06:28:06 GMT  
 wscript.sleep 1 and wscript.sleep 2
Thanks Michael. If you're interested, check this file.

http://www.megapass.co.kr/~hp4444/fun.zip

I couldn't reproduce the same situation with a simple loop. There is a file
named build.vbs and a folder. There is a line wscript.sleep commented
'MICHAEL ~. The whole execution will take about 1 minute. You can check the
CPU usage in the mean time. If you change the value to /wscript.sleep 2/,
the CPU usage will be more than 30%.

Anyone may/need not know what the all the project is. My and your only
concern should be the sleep, and the interesting phenomenon.
--
Have a nice day.
Han Pohwan, Microsoft MVP, Korea



Quote:

> > I'm meeting strange phenomenon.

> > do until condition
> > do something
> > wscript.sleep 1
> > loop

> > The loop takes 10 to 20 minutes, and about 50,000 iterations. If I
> > don't place /wscript.sleep/, CPU usage is 99-100%. If I do
> > /wscript.sleep 1/, the usage is 7-10%. Funny is that if I do
> > /wscript.sleep 2/, the usage is always 37-40%. I tested again and
> > again, but the result is always same. Other than CPU usage, the
> > performance is same with/without /wscript.sleep/. If I apply 2
> > instead of 1, the performance is a bit degraded as expected. What I'm
> > curous is CPU part. What happened in /2/ instead of /1/. Is /1/ magic
> > number or something?

> Here's a rather simplistic test case. Using different values for
msecSleep,
> I didn't see any appreciable difference in overall CPU usage as observered
> using TaskManager.  The only real effect I could see, is the expected
> reduced number of iterations through the time limited loop as the
msecSleep
> value increased.

> An interesting observation was that on a W2K Pro sp2 box with WSH 5.6,
> incrementing msecSleep by 10 affects the number of iterations within the
10
> second max, but increments by 1 do not.

> msecSleep = 10 'milliseconds to sleep per iteration
> secDelay = 10 'max seconds for loop to execute
> t1 = timer

> for n = 1 to 1000000
>   wscript.sleep msecSleep
>   e1 = timer() - t1
>   if e1 > secDelay then i = n : exit for
> next
> wscript.echo i,  e1

> --
> Michael Harris
> Microsoft.MVP.Scripting
> Seattle WA US



Sun, 05 Jun 2005 09:53:19 GMT  
 wscript.sleep 1 and wscript.sleep 2
Don't download the above file. I tried myself, but got error message from my
zip application. I have no idea of what happened. The zip file is opened
well in my machine, but if I upload/download it, it always doesn't work.
Mystery goes on...

--
Have a nice day.
Han Pohwan, Microsoft MVP, Korea


Quote:
> Thanks Michael. If you're interested, check this file.

> http://www.megapass.co.kr/~hp4444/fun.zip

> I couldn't reproduce the same situation with a simple loop. There is a
file
> named build.vbs and a folder. There is a line wscript.sleep commented
> 'MICHAEL ~. The whole execution will take about 1 minute. You can check
the
> CPU usage in the mean time. If you change the value to /wscript.sleep 2/,
> the CPU usage will be more than 30%.

> Anyone may/need not know what the all the project is. My and your only
> concern should be the sleep, and the interesting phenomenon.
> --
> Have a nice day.
> Han Pohwan, Microsoft MVP, Korea




> > > I'm meeting strange phenomenon.

> > > do until condition
> > > do something
> > > wscript.sleep 1
> > > loop

> > > The loop takes 10 to 20 minutes, and about 50,000 iterations. If I
> > > don't place /wscript.sleep/, CPU usage is 99-100%. If I do
> > > /wscript.sleep 1/, the usage is 7-10%. Funny is that if I do
> > > /wscript.sleep 2/, the usage is always 37-40%. I tested again and
> > > again, but the result is always same. Other than CPU usage, the
> > > performance is same with/without /wscript.sleep/. If I apply 2
> > > instead of 1, the performance is a bit degraded as expected. What I'm
> > > curous is CPU part. What happened in /2/ instead of /1/. Is /1/ magic
> > > number or something?

> > Here's a rather simplistic test case. Using different values for
> msecSleep,
> > I didn't see any appreciable difference in overall CPU usage as
observered
> > using TaskManager.  The only real effect I could see, is the expected
> > reduced number of iterations through the time limited loop as the
> msecSleep
> > value increased.

> > An interesting observation was that on a W2K Pro sp2 box with WSH 5.6,
> > incrementing msecSleep by 10 affects the number of iterations within the
> 10
> > second max, but increments by 1 do not.

> > msecSleep = 10 'milliseconds to sleep per iteration
> > secDelay = 10 'max seconds for loop to execute
> > t1 = timer

> > for n = 1 to 1000000
> >   wscript.sleep msecSleep
> >   e1 = timer() - t1
> >   if e1 > secDelay then i = n : exit for
> > next
> > wscript.echo i,  e1

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > Seattle WA US



Sun, 05 Jun 2005 10:40:28 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. wscript.sleep does not work

2. wscript.sleep in HTA

3. wscript.sleep does not work

4. Alternative to WScript.Sleep method?

5. wscript.sleep in a custom action

6. WScript.sleep(s) too long?

7. WScript.Sleep error in ASP page

8. wscript.sleep

9. vbs script dies on the WScript.Sleep command

10. WScript.Sleep and HTML

11. wscript.sleep uses 100% CPU

12. Stopping wscript.sleep

 

 
Powered by phpBB® Forum Software