Sign in to follow this  
Followers 0
Influx

share you dlls for speed

16 posts in this topic

I know by use of DLLS functions can be sped up (by using UDFs with the dll)

Basicaly what i would like is some speedly dlls for doing the following

*reading a file

*checking stringinsrt()

and any toher usefull ones you have laying arround.

thanks,

Influx

note:please include the udfs or instructions

Share this post


Link to post
Share on other sites



You could use Autoit's ActiveX Dll.

Share this post


Link to post
Share on other sites

wouldnt that still be just as slow as autoit?

if not what is an example dll call to read a file, and do a stringinstr() functions

Share this post


Link to post
Share on other sites

200kb-100MB files.

Autoit takes about half a second or more to read. C++ takes like 10/1000 of a second.

im attempting to rewrite in C++ bu ti dont know if it will be a sucess.

Share this post


Link to post
Share on other sites

200kb-100MB files.

Autoit takes about half a second or more to read. C++ takes like 10/1000 of a second.

im attempting to rewrite in C++ bu ti dont know if it will be a sucess.

It depends on how you read the file. Try use _WinAPI_ReadFile and you will get great speed :)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Extending my last post.

Here's an example that uses _WinAPI_ReadFile and the standard C library. The difference is significant!

#include <winapi.au3>



ConsoleWrite("Using pure AutoIt"&@CRLF)

$timer2=TimerInit()
$data=FileRead("test.data")
$pos=StringInStr($data,"andreas")

If $pos Then
    ConsoleWrite("Substring found at position: "&$pos&@CRLF)
Else
    ConsoleWrite("Substring not found"&@CRLF)
EndIf

ConsoleWrite("Total processing time: "&Round(TimerDiff($timer2))&" ms."&@CRLF&@CRLF)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


ConsoleWrite("Using WinAPI and the standard C library"&@CRLF)
$timer=TimerInit()
$fsize=FileGetSize("test.data")
$handle=_WinAPI_CreateFile("test.data",2,2)

$buffer=DllStructCreate("char["&$fsize+1&"]")
DllStructSetData($buffer,1,Chr(0),$fsize+1)

Local $red
_WinAPI_ReadFile($handle,DllStructGetPtr($buffer),$fsize,$red)
_WinAPI_CloseHandle($handle)

$call=DllCall("msvcrt.dll","ptr:cdecl","strstr","ptr",DllStructGetPtr($buffer),"str","andreas")

If $call[0] Then
    ConsoleWrite("Substring found at position: "&1+Dec(StringTrimLeft($call[0]-DllStructGetPtr($buffer),2))&@CRLF)
Else
    ConsoleWrite("Substring not found"&@CRLF)
EndIf

ConsoleWrite("Total processing time: "&Round(TimerDiff($timer))&" ms."&@CRLF)

Here's a script that creates the test file:

$str=""
For $i=0 To 10^6
    $str&=Chr(Random(97,122,1))
    If $i=Round(10^6/2) Then $str&="andreas"
Next
FileWrite("test.data",$str)

Results on my computer:

WinAPI+C lib = 2 ms.

AutoIt = 147 ms.

:)

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

@monoceres

I think I will now use _WinAPI_ReadFile instead of file read :)

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@monoceres

I think I will now use _WinAPI_ReadFile instead of file read :)

Cheers, FireFox.

Well just make sure you know how to handle a null-terminated C string. They're not quite as easy to work with as autoit's string type.

Oh and you should know that most of the difference is made in the finding of the substring. Just reading the file look like this:

AutoIt: 18 ms

_WinAPI_ReadFile: 1 ms


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

This is so strange. I mean, I know that devs are making things as robust as they can be (so that we don't brake something), but this is almost too much. What kind of file or error checking are they doing there?

Great comparison monoceres!


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

This is so strange. I mean, I know that devs are making things as robust as they can be (so that we don't brake something), but this is almost too much. What kind of file or error checking are they doing there?

Great comparison monoceres!

Yeah, however I just realized something.

My comparison wasn't really fair. StringInStr() is not case-sensitive by default which means that autoit needs to determine a whole lot more combinations. Changing StringInStr() to be case-sensitive makes the match a whole lot better:

_WinAPI_ReadFile + C Lib: 2 ms.

Pure AutoIt: 25 ms.

Sorry for that.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

It's a bit faster this like too:

$hwnd = FileOpen("test.data", 16)
$data = BinaryToString(FileRead($hwnd))
FileClose($hwnd)

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

question....

lol your code was confusing.

lets sat i just want to read database.viri to the variable $db... how would I do that?

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I find interesting that strstr function from msvcrt.dll can be found in ntdll.dll too.

Same calling convention, same everything. And that one is not the only one.

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

The one from ntdll.dll should be faster because you skip one step. Instead of calling the function from your application to msvcrt.dll to ntdll.dll you go from your application to ntdll.dll. If I'm not mistaken they should be in kernel32 too, still ntdll should be fastest.

Edited by Pain

Share this post


Link to post
Share on other sites

The one from ntdll.dll should be faster because you skip one step. Instead of calling the function from your application to msvcrt.dll to ntdll.dll you go from your application to ntdll.dll. If I'm not mistaken they should be in kernel32 too, still ntdll should be fastest.

In both cases they are not imported. Code is in msvcrt.dll as well as in ntdll.dll (this one have no imports at all). There should be no difference in speed.

But ntdll.dll is what they call "NT Layer DLL". Fundamental one.


♡♡♡

.

eMyvnE

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  
Followers 0