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 

Strange behavior; MsgBox slows down rest of script.

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
Raccoon



Joined: 02 Jan 2008
Posts: 60

PostPosted: Fri Feb 22, 2008 9:17 am    Post subject: Strange behavior; MsgBox slows down rest of script. Reply with quote

Try out the following code.

afunc() is a dummy 'slow' function to obtain a consistent usable speed reading.

The commented MsgBox command is the culprit here. With this line uncommented, the script actually processes more than 2x slower.

What is it about MsgBox that would cause an entire script to process 2x slower for the rest of its life?

Code:

afunc()
{
   Loop, 100000
      foo := mod(2147483647,13793728)
}


; msgbox xyzzy

ticks := A_TickCount

   afunc()

msgbox % A_TickCount - ticks


PS. I've also tried adding Sleep, 5000 after the offending MsgBox, just in case AHK is loading some common dialog dependencies in the background. However, results remain the same.

Until we understand why it's doing this, I'd recommend avoiding the use of MsgBox before any process intense loops.
Back to top
View user's profile Send private message
Oberon



Joined: 18 Feb 2008
Posts: 408

PostPosted: Fri Feb 22, 2008 11:36 am    Post subject: Reply with quote

I get the exact same number with and without a message box. There should be no interference, unless you have extremely low RAM. Also as a rule of thumb when benchmarking use SetBatchLines, -1 and Process, Priority, , R at the top of your script. Otherwise your script will be highly affected by your system state and clock thus giving inaccurate and inconsistent results.

Edit: upon further inspection with high resolution timers I noticed a 35% performance boost when MsgBox was not present. Given the nature of interpreted languages I understand that this is not so unusual.
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10450

PostPosted: Mon Mar 03, 2008 12:56 am    Post subject: Reply with quote

I get the same result both with and without the MsgBox.

Using a high resolution timer shouldn't affect the measuring in this case because the test takes a relatively long time to complete; that is, comfortably within the precision of TickCount.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports 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