monoceres Posted April 20, 2008 Share Posted April 20, 2008 Today I decided to write my own _FileSearch() function, mainly because the ones that uses DOS for their output didn't handle swedish characters very well. I also did some speed testing against other _FileSearch() that doesn't use DOS: Test: *.mp3 through 41k files. Geosoft: 125 seconds monoceres: 26 seconds Gary Frost: 45 seconds Anyways here's my code: ; _FileSearch() ; Example: _FileSearch("C:","*.au3") ; Author: Andreas Karlsson (monoceres) #include-once #include <File.au3> #include <array.au3> Func _FileSearch($initdir,$searchterm="*.*") Local $dirs[1] = [$initdir], $results[1] = [0] While True $tempdirs = _FileListToArray($dirs[0], "*.*", 2) $tempfiles = _FileListToArray($dirs[0], $searchterm, 1) For $i = 1 To UBound($tempfiles) - 1 _ArrayAdd($results, $dirs[0] & "\" & $tempfiles[$i]) $results[0] += 1 Next For $i = 1 To UBound($tempdirs) - 1 _ArrayAdd($dirs, $dirs[0] & "\" & $tempdirs[$i]) Next If UBound($dirs) > 1 Then _ArrayDelete($dirs, 0) Else ExitLoop EndIf WEnd Return $results EndFunc Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 20, 2008 Share Posted April 20, 2008 Yay, Sweden!! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Siao Posted April 20, 2008 Share Posted April 20, 2008 (edited) I also did some speed testing against other _FileSearch() that doesn't use DOSMaybe you should also compare with some functions that were actually written with performance as a goal, not just some old and generic code. Search for FileListToArray in this forum, and you'll find some improved versions of this official UDF, most notably by randallc and weaponx. Edited April 20, 2008 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
monoceres Posted April 20, 2008 Author Share Posted April 20, 2008 Maybe you should also compare with some functions that were actually written with performance as a goal, not just some old and generic code. Search for FileListToArray in this forum, and you'll find some improved versions of this official UDF, most notably by randallc and weaponx.I've just read Weaponxs FileListToArray post and now I see that my code, well lets face it sucks. At least now I have some really fast code to use Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 21, 2008 Share Posted April 21, 2008 Hi, I guess declaring the result array with lets say 1000 and then just adding without _ArrayAdd will be faster. Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
monoceres Posted April 21, 2008 Author Share Posted April 21, 2008 Hi,I guess declaring the result array with lets say 1000 and then just adding without _ArrayAdd will be faster.MegaYes but then we come to the eternal question, what if I have to use 1001 elements?It would be great if autoit could somehow make use of the new and delete keywords in c++, then we could see some really fast and dynamic arrays Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 21, 2008 Share Posted April 21, 2008 Yes but then we come to the eternal question, what if I have to use 1001 elements?It would be great if autoit could somehow make use of the new and delete keywords in c++, then we could see some really fast and dynamic arrays If you want to make it faster, then you can add a parameter which is set to 1000 and if somebody needs more than 1000 results --> change the parameter.MegaP.S.: Did you test ObjCreate("Scripting.FileSystemObject") for searching, may even be faster. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
GEOSoft Posted April 21, 2008 Share Posted April 21, 2008 P.S.: Did you test ObjCreate("Scripting.FileSystemObject") for searching, may even be faster.As a matter of fact, I was playing with that a week or so ago and found out it was slower than the one I already use. Slower by about 30% George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Xenobiologist Posted April 21, 2008 Share Posted April 21, 2008 Hi, you are right. It is slower. Sorry for that. Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times 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