Developers Jos Posted April 3, 2020 Developers Share Posted April 3, 2020 I took the simply way to test by writing this BCX file: DIM durarion! DIM RetVal% DIM test! ' Test before msgbox tstart! = TIMER test! = 0 FOR j% = 1 TO 1000000000 test! += 1 NEXT j% tend! = TIMER durarion! = tend! - tstart! PRINT "Elapsed time before msgbox" & STR$(durarion!) & " seconds" RetVal% = MSGBOX("This is a message", "Test", 3+64) ' Test after msgbox tstart! = TIMER test! = 0 FOR j% = 1 TO 1000000000 test! += 1 NEXT j% tend! = TIMER durarion! = tend! - tstart! PRINT "Elapsed time after before msgbox" & STR$(durarion!) & " seconds" Which then is converted to C and compiled with PellesC. This is the result: >test.exe Elapsed time before msgbox 2.609375 seconds Elapsed time after before msgbox 2.671875 seconds >Exit code: 0 Time: 6.025 So I guess that tell us there must be something happening with AutoIt3 when MSGBOX() is called SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Nine Posted April 3, 2020 Share Posted April 3, 2020 Thank you @Jos. That is what I was afraid of. Not only MsgBox, but any GUI display (except maybe Splash, re: jchd). “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Musashi Posted April 4, 2020 Share Posted April 4, 2020 On 4/2/2020 at 7:02 PM, Jos said: A call to MSGBOX is really a standard DLL call to MessageBoxW .... maybe one could try using that to see if that is similar? Since not all visitors of the german forum are also present here, I have mentioned this phenomenon in the DE-Forum as well. Here is a test script by @AndyG in which a direct call of the MessageBox takes place. german thread : https://autoit.de/thread/86867-msgbox-verlangsamt-den-skriptablauf-unter-win-10/?postID=699015#post699015 ConsoleWrite("> ------------------------------------------" & @CRLF) ConsoleWrite("> >>>>> Check 1.1 - Calc() before MsgBox <<<<< " & @CRLF) _Calc() $aResult = DllCall("user32.dll", "int", "MessageBox", "hwnd", 0, "str", "A", "str","B","int",1) ConsoleWrite("> >>>>> Check 1.2 - Calc() after MsgBox <<<<<" & @CRLF) _Calc() ConsoleWrite("> ------------------------------------------" & @CRLF) Func _Calc() Local $iTime, $iValue = 0 $iTime = TimerInit() For $i = 1 to 5000000 $iValue += 1 Next $iTime = TimerDiff($iTime) ConsoleWrite("! " & StringFormat("% 15s: %4.3f ms", "Elapsed time = ", $iTime) & @CRLF) EndFunc ;==>_Calc The result is similar to calling the AutoIt function MsgBox. Spoiler > ------------------------------------------ > >>>>> Check 1.1 - Calc() before MsgBox <<<<< ! Elapsed time = : 1506.213 ms > >>>>> Check 1.2 - Calc() after MsgBox <<<<< ! Elapsed time = : 8359.865 ms > ------------------------------------------ "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
jpm Posted April 5, 2020 Share Posted April 5, 2020 My modest contribution for a go around ConsoleWrite("> ------------------------------------------" & @CRLF) ConsoleWrite("> >>>>> Check 1.1 - Calc() before MsgBox <<<<< " & @CRLF) _Calc() ; Next show pb ======================= ;~ GUICreate("Test") ;~ GUISetState() ;~ GUIDelete() ; optional ;~ Local $aResult = DllCall("user32.dll", "int", "MessageBox", "hwnd", 0, "str", "A", "str","B","int",1) ;~ InputBox('inputbox', 'ok') ;~ Sleep(200) ; ; Workaround ========================= _MsgBox(0, "A", "B", 1) ConsoleWrite("> >>>>> Check 1.2 - Calc() after MsgBox <<<<<" & @CRLF) _Calc() ConsoleWrite("> ------------------------------------------" & @CRLF) Func _Calc() Local $iTime, $iValue = 0 #forceref $iValue $iTime = TimerInit() For $i = 1 To 5000000 $iValue += 1 Next $iTime = TimerDiff($iTime) ConsoleWrite("! " & StringFormat("% 15s: %4.3f ms", "Elapsed time = ", $iTime) & @CRLF) EndFunc ;==>_Calc Func _MsgBox($iFlag, $sTitle, $sText, $iTimeOut = 0) RunWait(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(' & $iFlag & ', ''' & $sTitle & ''', ''' & $sText & ''', ' & $iTimeOut & ')"') EndFunc ;==>_MsgBox Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2020 Share Posted April 5, 2020 (edited) Such workaround is pretty pointless: as soon as a window is shown, the slowdown happens. Global $hGui = GUICreate("Snail", 800, 600) AdlibRegister(timeit, 1000) Func timeit() Local $x Local $t = TimerInit() For $i = 1 To 500000 $x += 1 Next ConsoleWrite(TimerDiff($t) & @LF) EndFunc Sleep(3200) GUISetState(@SW_SHOW) ; *6 slow down on W10 ;~ MsgBox($MB_TASKMODAL, "", "Now look at times in console after me!") ; *6 slow down on W10 ;~ SplashTextOn("", "And during/after splash?") ; doesn't slow things down Sleep(3000) Spooning every GUI operation to a distinct process is impossible to deal with. That simply means AutoIt can become 6 times (for me) up to 10 times (for some other users) faster than it actually is after "showing" any kind of window under W10. That is, all of AutoIt GUI programs (old or current) launched under W10. That's a huge enough reason to drag Jon out of his lockdown cave quickly IMHO (assuming he's still alive). @trancexx help? Edited April 5, 2020 by jchd Made $CW a genuine ConsoleWrite TheDcoder and Musashi 1 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Musashi Posted April 5, 2020 Share Posted April 5, 2020 (edited) 2 hours ago, jpm said: My modest contribution for a go around Thanks for the quick response. This 'work-around' has already been posted by @Nine : https://www.autoitscript.com/forum/topic/202270-script-becomes-way-slower-after-a-msgbox-moved/?do=reportComment&comment=1451366 Unfortunately, in addition to MsgBox, almost all other GUI-related functionalities (and other things) have an impact on the described behavior as well. Wrapping all these functions by calling an own process using /AutoIt3ExecuteLine and/or /AutoIt3ExecuteScript would be the Overkill. Finally, only the developers have the deeper insight into the core processes of AutoIt and are able to find a real solution. Edited April 5, 2020 by Musashi typo "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 5, 2020 Moderators Share Posted April 5, 2020 Hi, It seems that the problem arises once a GUI is actually displayed - merely creating it, or hiding it, does not seem to have an effect: $nStart = TimerInit() $iX = 0 For $i = 1 To 500000 $iX += 1 Next ConsoleWrite("Initial: " & TimerDiff($nStart) & @CRLF) $hGUI = GUICreate("Test", 10, 10) $nStart = TimerInit() $iX = 0 For $i = 1 To 500000 $iX += 1 Next ConsoleWrite("Created: " & TimerDiff($nStart) & @CRLF) GUISetState(@SW_HIDE) $nStart = TimerInit() $iX = 0 For $i = 1 To 500000 $iX += 1 Next ConsoleWrite("Hidden: " & TimerDiff($nStart) & @CRLF) GUISetState(@SW_SHOW) $nStart = TimerInit() $iX = 0 For $i = 1 To 500000 $iX += 1 Next ConsoleWrite("Shown: " & TimerDiff($nStart) & @CRLF) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2020 Share Posted April 5, 2020 Correct, that's what my experiment shows. Forgot to post the hidden GUI timing though. Current AutoIt does "something" harmless under pre-W10, which reveals dramatically detrimental under W10. Around hooking the message pump or something like that, IDK, but the quirk lies inside our codebase for sure. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Nine Posted April 5, 2020 Share Posted April 5, 2020 After testing with killing dwm.exe (as I said above), it got 3 times faster. I also tried to suspend winlogon.exe and some other processes without success (I am getting black screen). Even though this is not a workaround, I believe it is a good trail to follow, to solve this major issue... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
UEZ Posted April 5, 2020 Share Posted April 5, 2020 No problem with FreeBasic: #include "string.bi" #Include Once "windows.bi" Sub Test(sMsg As String = "") Static As Uinteger iLoop = 1, iValue ? ">>>>> Check " & iLoop & " " & sMsg & " <<<<<<" Dim As Double iTime For j As Ubyte = 1 To 3 iTime = Timer iValue = 0 For i As Uinteger = 1 To 750000000 iValue += 1 Next ? "Elapsed Time " & j & ": " & (Timer - iTime) * 1000 & " ms" Next iLoop += 1 End Sub Test("") Messagebox(0, "Test", "Test", MB_OK) Test("after Messagebox call") ? "Done" Sleep Result: >>>>> Check 1 <<<<<< Elapsed Time 1: 1551.876600004633 ms Elapsed Time 2: 1447.948900000682 ms Elapsed Time 3: 1447.424899990367 ms >>>>> Check 2 after Messagebox call <<<<<< Elapsed Time 1: 1521.325099989142 ms Elapsed Time 2: 1518.602700001296 ms Elapsed Time 3: 1457.062300000217 ms Done Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2020 Share Posted April 5, 2020 I've also tried with several languages and only AutoIt exhibits the issue. It's deep inside AutoIt core guts. Also tried all Opt() settings just in case, but to no avail. Didn't yet find any relevant topic in dev platforms, so this is mostly unheard, meaning we can only rely on our own code dev team, if any. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
UEZ Posted April 5, 2020 Share Posted April 5, 2020 Same result if you call MsgBox native using DLLCall -> DllCall("user32.dll", "int", "MessageBox", "ptr", 0, "str", "Test", "str", "Test", "uint", 0) Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Developers Jos Posted April 5, 2020 Developers Share Posted April 5, 2020 Guess we need @Jon to return from hibernation. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Developers Jos Posted April 5, 2020 Developers Share Posted April 5, 2020 (edited) We can make the test even simpler, and this is inline with what @Melba23 posted earlier: $x = 0 $start = TimerInit() For $i = 1 To 500000 $x += 1 Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console ; Show the AutoIt3 hidden window WinSetState(AutoItWinGetTitle(), "", @SW_SHOW) $start = TimerInit() $x = 0 For $i = 1 To 500000 $x += 1 Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console Jos Edited April 5, 2020 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
seadoggie01 Posted April 5, 2020 Share Posted April 5, 2020 (edited) I like how the OP had these two lines swapped, so everyone else does now too. (Not that it matters at all) $x = 0 ; <-- Note, $x = 0 comes before timer $start = TimerInit() For $i = 1 To 500000 $x += 1 Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console ; Show the AutoIt3 hidden window WinSetState(AutoItWinGetTitle(), "", @SW_SHOW) $start = TimerInit() $x = 0 ; <-- Here, $x = 0 is after For $i = 1 To 500000 $x += 1 Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console Edited April 5, 2020 by seadoggie01 All my code provided is Public Domain... but it may not work. Use it, change it, break it, whatever you want. Spoiler My Humble Contributions:Personal Function Documentation - A personal HelpFile for your functionsAcro.au3 UDF - Automating Acrobat ProToDo Finder - Find #ToDo: lines in your scriptsUI-SimpleWrappers UDF - Use UI Automation more Simply-erKeePass UDF - Automate KeePass, a password managerInputBoxes - Simple Input boxes for various variable types Link to comment Share on other sites More sharing options...
UEZ Posted April 5, 2020 Share Posted April 5, 2020 (edited) If you place AutoItSetOption('GUIOnEventMode', 1) at the top of your script the script will be slower, too, without adding any GUI / Messagebox element. AutoItSetOption('GUIOnEventMode', 1) $start = TimerInit() $x = 0 For $i = 1 To 5000000 $x += 1 Next ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TimerDiff($start) = ' & TimerDiff($start) & @CRLF) ;### Debug Console Edited April 5, 2020 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Nine Posted April 5, 2020 Share Posted April 5, 2020 (edited) If you place those 2 statements, in my case, it computes to addition, so now it gets slower by 13 ! AutoItSetOption('GUIOnEventMode', 1) WinSetState(AutoItWinGetTitle(), "", @SW_SHOW) Edit : GuiOnEventMode has the same impact on Win7, about 3 times slower... Edited April 5, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2020 Share Posted April 5, 2020 (edited) Yes, when I tried playing with Opt() I noticed that GUIOnEventMode set will add a (relatively) constant slowndown, GUI shown or not. For me it's about 50% of the loop timing when no GUI is shown; GUI shown adds the same extra time. This comes with no surprise as that forces the core to setup its own machinery to conditionally intercept messages, wasting some cycles. Edited April 5, 2020 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Developers Jos Posted April 5, 2020 Developers Share Posted April 5, 2020 I also find it intriguing why the original case and the last one I showed does slow down the processing, but I also honestly feel some are exaggerating by stating this a major problem.... right? AutoIt3 was never built for speed of processing but rather speed and flexibility of creating scripts. Maybe Jon can shed some light on it whenever he's back. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
jchd Posted April 5, 2020 Share Posted April 5, 2020 Uhm... 600% to 1000% IS a real issue. 6% to 10% would be barely unnoticeable, but this is a really severe impact on effectiveness. Wtiness the large number of posts where speed or GUI responsiveness is the key. I'm nowhere attacking AutoIt and on the contrary would love to see this bottleneck fixed quickly to be proud again of the language. Musashi and seadoggie01 2 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now