| View previous topic :: View next topic |
| Author |
Message |
Raccoon
Joined: 02 Jan 2008 Posts: 60
|
Posted: Fri Feb 22, 2008 9:17 am Post subject: Strange behavior; MsgBox slows down rest of script. |
|
|
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 |
|
 |
Oberon
Joined: 18 Feb 2008 Posts: 408
|
Posted: Fri Feb 22, 2008 11:36 am Post subject: |
|
|
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 |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10450
|
Posted: Mon Mar 03, 2008 12:56 am Post subject: |
|
|
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 |
|
 |
|