Directory reading slow when using #PB_Any

Everything else that doesn't fall into one of the other PB categories.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Directory reading slow when using #PB_Any

Post 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
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Directory reading slow when using #PB_Any

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Directory reading slow when using #PB_Any

Post by uwekel »

Great! Thanks a lot! I didn't expect that at all!
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Post Reply