Jump to content



Photo

Integrated function _FileListToArray improvement?


  • Please log in to reply
31 replies to this topic

#1 Tlem

Tlem

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 279 posts

Posted 14 June 2009 - 11:52 PM

Hello everybody.
In my search of filelist function, I read the File.au3 UDF to see how _FileListToArray was writing.
And in the code I saw that it work directly with array.
I noticed that this approach is slower than using strings and create the array in the end.

So, this is what I noticed on my laptop IBM R60 :
If I use standard _FileListToArray function, the time to do the trip on my @SystemDir is about : 49ms
If I modify the function to use strings, the time decreases to 32ms. :D

Well, 17ms isn't a long time, but my @SystemDir contains only 2497 elements.

For information, I make a test on my @WindowsDir (211 elements), and the difference between time is only of 1ms.

I don't know if it's a good idea to make the modification, but I put it here in case of. :D
Plain Text         
Func _FileListToArray($sPath, $sFilter = "*", $iFlag = 0)     Local $hSearch, $sFile, $sFileList, $asFileList[1]     If Not FileExists($sPath) Then Return SetError(1, 1, "")     If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")     If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")     If (StringMid($sPath, StringLen($sPath), 1) = "\") Then $sPath = StringTrimRight($sPath, 1); needed for Win98 for x:\  root dir     $hSearch = FileFindFirstFile($sPath & "\" & $sFilter)     If $hSearch = -1 Then Return SetError(4, 4, "")     While 1         $sFile = FileFindNextFile($hSearch)         If @error Then             SetError(0)             ExitLoop         EndIf         If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop         If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop         $sFileList &= $sFile & "|"     WEnd     FileClose($hSearch)     $asFileList = StringSplit(StringTrimRight($sFileList, 1), "|")     Return $asFileList EndFunc  ;==>_FileListToArray

Best Regards.Thierry





#2 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 16 June 2009 - 08:50 AM

It sounds good to me.

I think this is good idea.

#3 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 16 June 2009 - 08:58 AM

There is a limit with string length though isn't there? What happens if we reach that limit?

#4 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 16 June 2009 - 01:13 PM

There is a limit with string length though isn't there? What happens if we reach that limit?

I think it's 2GB (or amount of addressable RAM in OS limit) so it shouldn't be problem.

#5 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,692 posts

Posted 16 June 2009 - 02:36 PM

A large string can still become cumbersome to process. Remember that when appending a string, a copy has to be made to append to.

#6 jpm

jpm

    a Real GUI/debug lover

  • Developers
  • 8,925 posts

Posted 16 June 2009 - 02:43 PM

        $sFileList &= $sFile & "|"

This statement will do a lot of memory allocation/deallocation so I suggest that for this small improvement we don't change it. :D

#7 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 16 June 2009 - 03:36 PM

        $sFileList &= $sFile & "|"
This statement will do a lot of memory allocation/deallocation so I suggest that for this small improvement we don't change it. :D

In original function there is ReDim $asFileList[UBound($asFileList) + 1] inside loop which does lot of memory allocation/deallocation too.

So developers should consider which of thouse is better.

#8 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 16 June 2009 - 03:58 PM

You guys are really starting to annoy me with this function. Everybody has an opinion on how this function should behave or should be implemented. Shut up and use what you have. We will never see the end of revisions if you want to tweak it because there will always be somebody better than you who can come along and make it "better".

#9 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,563 posts

Posted 16 June 2009 - 04:05 PM

You guys are really starting to annoy me with this function. Everybody has an opinion on how this function should behave or should be implemented. Shut up and use what you have. We will never see the end of revisions if you want to tweak it because there will always be somebody better than you who can come along and make it "better".

I'm beginining to think that no UDFs should be included with AutoIt. Let people write their own versions and post them on Example Scripts. This is becoming a never ending problem.
GeorgeQuestion 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!"

#10 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 16 June 2009 - 04:10 PM

I'm beginining to think that no UDFs should be included with AutoIt. Let people write their own versions and post them on Example Scripts. This is becoming a never ending problem.

People just need to get it through their stupid heads that we dot not have to do everything for them. If they can make modifications to something they need to shut the fuck up and use it. Or post it on the forum if they want to share. A significant amount of community feedback can drive feature change but not one random person saying "hey I can do that better".

#11 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,563 posts

Posted 16 June 2009 - 04:47 PM

I'm probably still running in PMS mode but to me these posts are becoming a nuisance in general.
GeorgeQuestion 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!"

#12 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 16 June 2009 - 05:00 PM

@Valik



No need to be rude here.

Just say: "It will not be done in any way" and we will understand that :-)

#13 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 16 June 2009 - 05:45 PM

Zedna, it's frustrating. People aren't happy they can do something. It must be built-in or at least in a UDF distributed by us. It's absurd how some people can't use code unless we are somehow involved with the distribution of it.

#14 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,686 posts

Posted 16 June 2009 - 06:32 PM

Probably the need to feel special, the want to have contributed something to such an amazing product. Neither are really bad traits, but agreed it should be done through feedback. That's how I've gotten my UDF's included. Yet they have I believe all been changed/upgraded/fixed but it also was done through the community and tried over and over again before it was included in the actual UDF releases. People don't understand the concept of using the community to test. Not just simply saying I think this is better for this theoretical reason. Prove it. Have more than yourself as proof. Then it may still be declined on the concept of this function is good enough for general consumption.

Oh well...GEOSoft...buddy they make Midol for that PMS stuff you're referencing :D

Jarvis
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#15 KaFu

KaFu

    Hey, it's just me, KhaFoo...

  • MVPs
  • 3,162 posts

Posted 16 June 2009 - 07:59 PM

Hmmm, but Tlem still points a valid argument imho. The UDFs (and examples; and examples of normal functions as well) are not always the 'most efficient' one's or in some cases even up-to-date. Guys, no offense meant, we all do this in our spare time... just an idea throw into the ring, might a (tightly moderated) UDF/Function Wiki be a... not solution, but improvement? The articles get a release stamp and on new releases creating a .chm file from the wiki should be possible...

#16 Tlem

Tlem

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 279 posts

Posted 16 June 2009 - 09:27 PM

I am really sorry to have started such a reaction while my purpose was to participate like some other.
My knowledge being very limited, so I believed to make by exposing the result of my researches and tests.

I would never have imagined such a rude reaction.

It makes 3 times that I try to participate and 3 times the reaction of developers in summer inequitable.
So in the future, I would keep my reflections for the French forum and as 80 % of the users of this program and forum, I would take without giving (here).

Thus, forgive my cheek, I would see to it not to begin again any more.
Best Regards.Thierry

#17 Zedna

Zedna

    AutoIt rulez!

  • MVPs
  • 8,315 posts

Posted 16 June 2009 - 09:45 PM

Tlem if you know this forum better you would know Valik is quite rude/not friendly/pesimistic almost all the time.

So don't take it personally. It's just the fact: One of the developers is not so friendly as others here.

Now I'm a bit scarred because of my ticket related to _FileListToArray() :-)

http://www.autoitscript.com/trac/autoit/ticket/966

#18 evilertoaster

evilertoaster

  • Active Members
  • PipPipPipPipPipPip
  • 1,203 posts

Posted 16 June 2009 - 09:53 PM

I would never have imagined such a rude reaction.


Tlem if you know this forum better you would know Valik is quite rude/not friendly/pesimistic almost all the time.

So don't take it personally. It's just the fact: One of the developers is not so friendly as others here.


It's quite well documented as one of the forums only 2 FAQ's-
http://www.autoitscript.com/forum/index.php?showtopic=37739

Do take it personal. Even still, so what...?

#19 Tlem

Tlem

    Universalist

  • Active Members
  • PipPipPipPipPip
  • 279 posts

Posted 16 June 2009 - 10:00 PM

I read well some posts about Valik and about his ego.
But I find surprising the reactions on this forum which it wants a forum of help and of improvement of AutoIt.

I understands whether it is their baby, but if the assistant brought by the members of the forum is systematically subject to pledge, then it is better than we let make these sirs.

I have for my part enough work on the French forum by making what I can to help the members with my little knowledge.

Thus once again, sorry to have disturbed you, I return in furtive mode. :D

Edited by Tlem, 16 June 2009 - 10:06 PM.

Best Regards.Thierry

#20 Valik

Valik

    Former developer.

  • Active Members
  • PipPipPipPipPipPip
  • 18,879 posts

Posted 16 June 2009 - 10:04 PM

I read well some posts about Valik and about his ego.

Then you read posts written by idiots. I. Do. Not. Have. An. Ego.

I really don't know how to make it any more clear than that. Far too many people make an assumption that just because I call somebody stupid or an idiot I am somehow asserting my superiority over everyone. Until the day I state "I am better than everybody" drop the ego bullshit. Stating somebody is stupid does not equate to stating I am better than somebody.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users