Page 1 of 1

Directory reading slow when using #PB_Any

Posted: Thu Apr 12, 2012 7:58 pm
by uwekel
Hi,

today i wrote a procedure to read out a directory recursively to return all filenames contained in a folder and all sub-folders. Playing around with it, i noticed that the procedure tooks more time the more often it gets called. After some further testing, i wrote this sample code to demonstrate the behaviour:

Code: Select all

For i = 1 To 5
  e = ElapsedMilliseconds()
  For j = 1 To 1000
    d = ExamineDirectory(#PB_Any, GetHomeDirectory(), "*.*")
    While NextDirectoryEntry(d)
    Wend
    FinishDirectory(d)
  Next
  Debug ElapsedMilliseconds() - e
Next
If you change the #PB_Any value to a number (e.g. 0), the procedure keeps fast all the time. I guess there is something odd with the management of the #PB_Any values.

Best regards,
Uwe

Re: Directory reading slow when using #PB_Any

Posted: Thu Apr 12, 2012 8:21 pm
by ts-soft
Please, no timetest with debugger! The result is absolute useless!

Code: Select all

For i = 1 To 5
  e = ElapsedMilliseconds()
  For j = 1 To 1000
    d = ExamineDirectory(#PB_Any, GetHomeDirectory(), "*.*")
    While NextDirectoryEntry(d)
    Wend
    FinishDirectory(d)
  Next
  a + ElapsedMilliseconds() - e
Next 

MessageRequester("", Str(a))

Code: Select all

For i = 1 To 5
  e = ElapsedMilliseconds()
  For j = 1 To 1000
    d = ExamineDirectory(1, GetHomeDirectory(), "*.*")
    While NextDirectoryEntry(1)
    Wend
    FinishDirectory(1)
  Next
   a + ElapsedMilliseconds() - e
Next 

MessageRequester("", Str(a))
There is no real difference

Re: Directory reading slow when using #PB_Any

Posted: Thu Apr 12, 2012 8:25 pm
by uwekel
Great! Thanks a lot! I didn't expect that at all!