Posts: 1,058
Threads: 367
Joined: Oct 2007
I use a rather simple code to enumerate folders under a root directory, which it contains about 5000 sub-folders. The first time this code is run after booting-up it takes about 150s (seconds). Every consequent run takes only 1-2 s. I understand it has something to do with XP. Any explanation and/or advice to avoid this annoying delay is most welcome. Best regards.
Function
tempf07
long t1 t2 dt
t1=perf ;;get time before
str sFolder="S:\Sdoc\*"
str sPath
Dir d
foreach(d sFolder FE_Dir 5)
,sPath=d.FileName(1)
,out sPath
t2=perf ;;get time after
dt=t2-t1 ;;display the difference
out F"{dt}"
Posts: 12,097
Threads: 142
Joined: Dec 2002
It is normal on all Windows versions. Probably because of slow disk access, because file properties are stored there. Next time faster because of caching. Probably faster if using SSD drive.
QM uses Windows API FindFirstFile/FindNextFile. I also tested FindFirstFileEx with options FindExInfoBasic (no DOS filename) and FIND_FIRST_EX_LARGE_FETCH that are available on Win7+, but it makes only 30% faster. No other faster API exist.
Times on my Win10 computer with SSD:
Macro
Macro2637
out
PerfFirst
str sFolder="C:\*"
str sPath
Dir d
int n
;foreach(d sFolder FE_Dir 5)
foreach(d sFolder FE_Dir 6)
,sPath=d.FileName(1)
,out sPath
,n+1
PerfNext;PerfOut
out n
;n: 500974 files+folders, 92897 folders
;FindFirstFile:
;speed: 31608175 after reboot. for files+folders (63 micros/file)
;speed: 11242001 later
;FindFirstFileEx(...FindExInfoBasic..FIND_FIRST_EX_LARGE_FETCH):
;speed: 19987875 after reboot
;speed: 6496472 later
Posts: 1,058
Threads: 367
Joined: Oct 2007
Dear Gintaras, many thanks for a very detailed and clear answer. Best regards.