Jump to content
Sign in to follow this  
Sunaj

Is using Dllopen faster?

Recommended Posts

Sunaj

Easy question (at least for a dev) here: is there any latency/speed gain associated with using Dll handles (made with dllopen..) in Dllcall? If yes is it big, small etc..? I realize that the difference will of course depend on the dll and the function used in question (fishing for generalities here). :) The pragmatic reason behind my question is that I have a script that uses about 5-10 dll calls for primary usage and a search and replace with some dllhandles, so that "user32.dll" becomes $dllUser32, would be fairly easy if there's gain to be had!

Cheers,

Sunaj

Share this post


Link to post
Share on other sites
lod3n

I think It's only faster if you make more than 2 calls to any given DLL. You should run a test yourself and see if it's faster for you one way or the other. You can use TimerInit and TimerDiff to find out how many milliseconds in execution time you're getting.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites
PaulIA

Easy question (at least for a dev) here: is there any latency/speed gain associated with using Dll handles (made with dllopen..) in Dllcall? If yes is it big, small etc..? I realize that the difference will of course depend on the dll and the function used in question (fishing for generalities here). :) The pragmatic reason behind my question is that I have a script that uses about 5-10 dll calls for primary usage and a search and replace with some dllhandles, so that "user32.dll" becomes $dllUser32, would be fairly easy if there's gain to be had!

Cheers,

Sunaj

I ran some tests on this when I first started designing Auto3Lib. The speed difference between keeping the handle open and using the string is very small. So small that I stopped caching the handles and switched to using the strings.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites
Sunaj

I think It's only faster if you make more than 2 calls to any given DLL. You should run a test yourself and see if it's faster for you one way or the other. You can use TimerInit and TimerDiff to find out how many milliseconds in execution time you're getting.

I ran some tests on this when I first started designing Auto3Lib. The speed difference between keeping the handle open and using the string is very small. So small that I stopped caching the handles and switched to using the strings.

Thanks to you both for your answers, @lod3n: you're right on the TimerInit/Diff usage to get the specifics (and yep, I do use the calls more than 2 times over). @PaulIA: I can see why you would choose that course when developing something as huge as Auto3Lib, it is however very easy for me to open the few handles I need so think I'll go with that options since you both agree that there is some (more or less tangible) gain to be had. Thanks for helping out. :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×