AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SetBatchLines, 20ms is 50% faster than 15ms??

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Ginger
Guest





PostPosted: Tue May 13, 2008 9:10 pm    Post subject: SetBatchLines, 20ms is 50% faster than 15ms?? Reply with quote

Code:

x := 20

a := A_TickCount
SetBatchLines, %x%ms
Loop, 1000
{
   Loop, 10000
   {
      h++
   }
}
b := A_TickCount
MsgBox, % b - a


SetBatchLines, 20ms is 50% faster than SetBatchLines 15ms. Why is it like that?

As I understand it SetBatchLines is how long the script should run before sleeping for 10ms. If that would have been the case then 20ms should be running at 20/(20+10)=66% speed while 15ms should be running at 15/(15+10)=60% speed.

In other words 20ms should be running (66-60)/60=10% faster than 15ms, not 50% faster.

Why is it 50% and not 10%
Back to top
Ginger
Guest





PostPosted: Tue May 13, 2008 9:30 pm    Post subject: Reply with quote

Here is a better illustration
Code:

Loop, 20
{
   x := 5+A_Index-1
   a := A_TickCount
   SetBatchLines, %x%ms
   Loop, 1000
   {
      Loop, 1000
      {
         h=0
         h++
         h--
      }
   }
   b := A_TickCount
   out .= "SetBatchLines, " x "ms " "`t" b-a "ms" "`r`n"
}
MsgBox, % out


The results are surprising to me:
Code:

SetBatchLines, 5ms    1593ms
SetBatchLines, 6ms    1625ms
SetBatchLines, 7ms    1625ms
SetBatchLines, 8ms    1594ms
SetBatchLines, 9ms    1625ms
SetBatchLines, 10ms    1625ms
SetBatchLines, 11ms    1594ms
SetBatchLines, 12ms    1562ms
SetBatchLines, 13ms    1594ms
SetBatchLines, 14ms    1594ms
SetBatchLines, 15ms    1594ms
SetBatchLines, 16ms    1187ms
SetBatchLines, 17ms    1078ms
SetBatchLines, 18ms    1078ms
SetBatchLines, 19ms    1079ms
SetBatchLines, 20ms    1078ms
SetBatchLines, 21ms    1078ms
SetBatchLines, 22ms    1078ms
SetBatchLines, 23ms    1078ms
SetBatchLines, 24ms    1109ms
Back to top
Oberon



Joined: 18 Feb 2008
Posts: 458

PostPosted: Tue May 13, 2008 9:49 pm    Post subject: Reply with quote

The system sleep resolution usually varies between 10ms and 20ms so benchmarking micro-delays is too volatile for reliable results. This is briefly mentioned in the documentation. Sleep is the antithesis of performance lolz.
Back to top
View user's profile Send private message
Ginger
Guest





PostPosted: Tue May 13, 2008 11:58 pm    Post subject: Reply with quote

I got the same result running the test several times. Jumps between 15ms, 16ms and 17ms. Other ms changes doing nothing.
Back to top
Giner
Guest





PostPosted: Wed May 14, 2008 10:43 pm    Post subject: Reply with quote

Any more comments? Is this the way it is supposed to be? If I want to make my script 10%, 20%, or 30% slower but not 50% slower, is there any work around?

Anyone? engunner?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group