Page 1 of 1

(SOLVED) [AHK2] A_LoopFileFullPath is over 10 times slower than in AHK1

Posted: 27 Aug 2018, 05:14
by HakitoJin
Edit : { Not a bug, A_LoopFileLongPath was changed to A_LoopFileFullPath in AHK2... }


Here's a comparison:
Image

And it gets exponentially worse the more files there are, for example, looping through 'C:\Windows\SysWOW64'...
A_LoopFilePath: 13,494
A_LoopFileFullPath: 2,534,414
Files: 2,855
Performance drop: 187 times
I am using the system directory as an example, but this happens everywhere.

Code for AHK1:

Code: Select all

;AHK1
DllCall("QueryPerformanceCounter","Int64*",StartTime)
Loop Files,% A_WinDir "\*.*"
	PokeTheVariable:=A_LoopFilePath
DllCall("QueryPerformanceCounter","Int64*",EndTime)

DllCall("QueryPerformanceCounter","Int64*",StartTime1)
Loop Files,% A_WinDir "\*.*"
	PokeTheVariable:=A_LoopFileFullPath
DllCall("QueryPerformanceCounter","Int64*",EndTime2)	

Msgbox % "AHK1`nA_LoopFilePath: `t" EndTime-StartTime "`nA_LoopFileFullPath: `t" EndTime2-StartTime1
Code for AHK2:

Code: Select all

;AHK2
DllCall("QueryPerformanceCounter","Int64*",StartTime)
Loop Files,A_WinDir "\*.*"
	PokeTheVariable:=A_LoopFilePath
DllCall("QueryPerformanceCounter","Int64*",EndTime)

DllCall("QueryPerformanceCounter","Int64*",StartTime1)
Loop Files,A_WinDir "\*.*"
	PokeTheVariable:=A_LoopFileFullPath
DllCall("QueryPerformanceCounter","Int64*",EndTime2)	

Msgbox "AHK2`nA_LoopFilePath: `t" EndTime-StartTime "`nA_LoopFileFullPath: `t" EndTime2-StartTime1

Re: [AHK2] A_LoopFileFullPath is over 10 times slower than in AHK1

Posted: 27 Aug 2018, 06:52
by swagfag
on v1 A_LoopFilePath and A_LoopFileFullPath both call the same function.
on v2 A_LoopFilePath calls A_LoopFilePath same as v1, but A_LoopFileFullPath calls the v1 equivalent of A_LoopFileLongPath, which is a different function entirely
the benchmark measures different functions

Re: [AHK2] A_LoopFileFullPath is over 10 times slower than in AHK1

Posted: 27 Aug 2018, 06:57
by guest3456
https://autohotkey.com/v2/v2-changes.htm
Renamed:

A_LoopFileFullPath -> A_LoopFilePath (returns a relative path if the Loop's parameter was relative, so "full path" was misleading)
A_LoopFileLongPath -> A_LoopFileFullPath

Re: [AHK2] A_LoopFileFullPath is over 10 times slower than in AHK1

Posted: 27 Aug 2018, 07:41
by just me