 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SKAN
Joined: 26 Dec 2005 Posts: 5298
|
Posted: Mon Apr 21, 2008 8:25 pm Post subject: |
|
|
@corrupt:
| Code: | Loop, %A_Windir%\*.* {
File := A_LoopFileName, DllCall( "shlwapi.dll\PathRemoveExtensionA", Str,File )
MsgBox, % File
} |
 |
|
| Back to top |
|
 |
Oberon
Joined: 18 Feb 2008 Posts: 408
|
Posted: Mon Apr 21, 2008 8:56 pm Post subject: |
|
|
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 |
|
 |
Guest
|
Posted: Mon Apr 21, 2008 8:59 pm Post subject: |
|
|
---------------------------
test.ahk
---------------------------
DllCall: 906
SubStr: 438
RegEx: 375
Time in ms over 250000 tests.
---------------------------
OK
--------------------------- |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|