AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

New Built-In File Loop Variable: A_LoopFileNameNoExt
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List
View previous topic :: View next topic  
Author Message
SKAN



Joined: 26 Dec 2005
Posts: 5298

PostPosted: Mon Apr 21, 2008 8:25 pm    Post subject: Reply with quote

@corrupt:

Code:
Loop, %A_Windir%\*.* {
 File := A_LoopFileName, DllCall( "shlwapi.dll\PathRemoveExtensionA", Str,File )
 MsgBox, % File
}


Smile
Back to top
View user's profile Send private message
Oberon



Joined: 18 Feb 2008
Posts: 408

PostPosted: Mon Apr 21, 2008 8:56 pm    Post subject: Reply with quote

That's interesting Skan, I decided to benchmark and made some surprising observations...

Code:
SetBatchLines, -1
Process, Priority, , R

p = .\file.-1..txt
i = 250000

hModule := DllCall("LoadLibrary", "Str", "shlwapi.dll")
r = %p%
RegExMatch(r, ".+(?=.)", r)

t0 = %A_TickCount%
Loop, %i% {
   r = %p%
   DllCall("shlwapi.dll\PathRemoveExtensionA", "Str", r)
}

t1 = %A_TickCount%
Loop, %i% {
   r = %p%
   r := SubStr(r, 1, InStr(r, ".", "", 0) - 1)
}

t2 = %A_TickCount%
Loop, %i% {
   r = %p%
   RegExMatch(r, ".+(?=\.)", r)
}

t3 = %A_TickCount%
DllCall("FreeLibrary", "UInt", hModule)
MsgBox, % "DllCall:`t" . t1 - t0 . "`nSubStr:`t" . t2 - t1 . "`nRegEx:`t" . t3 - t2
   . "`n`nTime in ms over " . i . " tests."


On my core 2 duo 2ghz lappy I got the following results:

Quote:
DllCall: 952
SubStr: 406
RegEx: 358

Time in ms over 250000 tests.


This suggests that regex is almost three times faster than winapi functions. This is most probably due the overheads involved with dynamically importing functions, but pcre is extremely fast and this proves it.
_________________
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Apr 21, 2008 8:59 pm    Post subject: Reply with quote

---------------------------
test.ahk
---------------------------
DllCall: 906
SubStr: 438
RegEx: 375

Time in ms over 250000 tests.
---------------------------
OK
---------------------------
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Wish List All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group