Kilmatead Posted October 24, 2012 Share Posted October 24, 2012 Noting the help file's suggestion that if calling _IsPressed() in a loop, it's the better part of valour to DLLOpen the common library user32 first, I'm also noting there is no explanation proffered as to why. I understand that single-calls presumably open/call/close the DLL, so it may be an abstract matter of "overhead" in an endless loop - but does this apply to a mere "few thousand" calls as well?For example, perusing the GuiTreeView.au3 UDF file, pretty much all of the "interesting" functions are ultimately using _SendMessage(), which is a user32 DLL call - however these functions (unlike _IsPressed) aren't built to easily pass an open library handle through.So if I have a routine that iteratively calls _GUITreeView_Expand() 8,000 times, and then stops (thus not an endless loop), is it worth my while to rewrite the necessary UDF's to allow open-handle passing? A few simple tests show that the world doesn't come to an end, and the devil doesn't seem to be bartering for my first-born or anything like that if I just submit the 8,000 calls one way or the other (no dramatic speed increases, etc).So, when not being contained in an endless loop, but merely a semantically long one, do I gain anything other than a Best Practise star on my forehead for rewriting the UDF's? Given the example, it's quite easy to just breakdown _GUITreeView_Expand() into its base _SendMessage() component, but - say - taking the time to rewrite _GUICtrlTreeView_SetStateImageIndex() for no discernible benefit could be depressing, when you look at how it's written. Link to comment Share on other sites More sharing options...
FireFox Posted October 24, 2012 Share Posted October 24, 2012 (edited) It's faster to open the dll, make as many calls as you want, then closing the dll instead of opening and closing it everytime. Proof : #include <Misc.au3> Global $iTimer, $hDLL $iTimer = TimerInit() $hDLL = DllOpen("user32.dll") For $i = 0 To 100000 _IsPressed("01", $hDLL) Next DllClose($hDLL) ConsoleWrite(TimerDiff($iTimer) / 1000 & " secs" & @CRLF) $iTimer = TimerInit() For $i = 0 To 100000 _IsPressed("01") Next ConsoleWrite(TimerDiff($iTimer) / 1000 & " secs" & @CRLF) 1.49700709421916 secs 1.75105206354706 secs Br, FireFox. Edited October 24, 2012 by FireFox Link to comment Share on other sites More sharing options...
trancexx Posted October 24, 2012 Share Posted October 24, 2012 ^^ this is not entirely true. Things are not black and white like that. When you DllOpen some module then AuoIt keeps track of all opened modules and iterates through a set of handles every time you pass dll handle. Same thing is done on lower level by the system with included reference count when you pass the string. Obviously AutoIt can do it slower than system does it depending on, for example the number of opened handles. It can also do it faster if ref count for the module drops to 0. So no, it's not black and white. FireFox 1 ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JScript Posted October 24, 2012 Share Posted October 24, 2012 @trancexx But apparently it is much faster do not you agree? JS http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!) Somewhere Out ThereJames Ingram Download Dropbox - Simplify your life!Your virtual HD wherever you go, anywhere! Link to comment Share on other sites More sharing options...
FireFox Posted October 24, 2012 Share Posted October 24, 2012 @trancexx I was almost sure that I was not entirely right. But I could not know what you said, too advanced for me. (at least for a short time I hope) Link to comment Share on other sites More sharing options...
JohnOne Posted October 24, 2012 Share Posted October 24, 2012 Natural progression might raise the question then, how can one enumerate open handles of a particular module? If OpenHandles("User32.dll") < 100 Then $Handle = DllOpen("the.dll") _Func($Handle) Else _Func("the.dll") EndIf Or is that just too silly? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Beege Posted October 25, 2012 Share Posted October 25, 2012 (edited) Natural progression might raise the question then, how can one enumerateopen handles of a particular module?If OpenHandles("User32.dll") < 100 Then$Handle = DllOpen("the.dll")_Func($Handle)Else_Func("the.dll")EndIfOr is that just too silly?Theres _WinAPI_EnumProcessModules and _WinAPI_EnumProcessHandles in It is silly though.. Edited October 25, 2012 by Beege Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator 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