Albireo wrote: ↑21 Jun 2019, 18:25
Below is the AHK code I used.
To perform the tests I chose the
input file, and configured
Goto to different test codes
I ran your test. Here is my script.
Code: Select all
/*
#SingleInstance,Force
SetBatchLines,-1
FileDelete,%A_ScriptDir%\Test File.txt
temp:=""
Loop, 10000 {
if(Mod(A_Index,4)=0){
temp.= "`n"
}else {
Temp .= "Some Random Text`n"
}
}
FileAppend,%Temp%,%A_ScriptDir%\Test File.txt
SoundBeep, 500
return
*ESC::ExitApp
*/
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
#Persistent
#SingleInstance Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
StartTime := A_TickCount
; FileRead InputCSV, c:\temp\FDT_ART_100.txt ; File1
FileRead InputCSV, %A_ScriptDir%\Test File.txt ; File2
Goto Example4 ; Example 1-4 ;<--------- ran each 10 times to get fastest and longest times
ExitApp
Example1: ; Test1 @Helbent ;<-------------------- 31 - 63 ms
InputData := StrSplit(InputCSV, "`n")
Loop % Index := InputData.Length()
( StrLen(InputData[Index]) < 1 )?(InputData.RemoveAt(Index--)):(Index--)
StopTime := A_TickCount
CountTime := StopTime - StartTime
MsgBox ,, Row %A_LineNumber% -> %A_ScriptName%, % "Ex1 `nNumber of rows .: " InputData.Count()"`nRunTime .: " CountTime " ms"
ExitApp
Example2: ; Test @Helbent ;<-------------------- 31 - 93 ms
InputData := StrSplit(InputCSV, "`n")
Index:=InputData.Length()
Loop,% InputData.Length() {
If( StrLen(InputData[Index]) < 1 )
InputData.RemoveAt(Index)
Index--
}
StopTime := A_TickCount
CountTime := StopTime - StartTime
MsgBox ,, Row %A_LineNumber% -> %A_ScriptName%, % "Ex2 `nNumber of rows .: " InputData.Count()"`nRunTime .: " CountTime " ms"
ExitApp
Example3: ; Test @just me ;<-------------------- 125 - 157 ms
InputData := []
DataIndex := 0
For LineIndex, Line In StrSplit(InputCSV, "`n")
{ LineCount := LineIndex
If StrLen(Line)
{ DataIndex += 1
InputData[DataIndex] := Line
}
}
DataLines := ""
For Each, Line In InputData
DataLines .= "`n" Line
StopTime := A_TickCount
CountTime := StopTime - StartTime
MsgBox ,, Row %A_LineNumber% -> %A_ScriptName%, % "Ex3 `nNumber of rows .: " InputData.Count()"`nRunTime .: " CountTime " ms"
ExitApp
Example4: ; Test @SpeedMaster ;<-------------------- 1938 - 2063 ms
InputData := StrSplit(InputCSV, "`n")
Loop, % InputData.Length()
(z:=InputData.Pop()) ? (InputData.InsertAt(1,z))
StopTime := A_TickCount
CountTime := StopTime - StartTime
MsgBox ,, Row %A_LineNumber% -> %A_ScriptName%, % "Ex4 `nNumber of rows .: " InputData.Count()"`nRunTime .: " CountTime " ms"
ExitApp
I ran each one 10 times and recorded the fastest and slowest times.
Example 1: 31 - 63 ms
Example 2: 31 - 93 ms
Example 3: 125 - 157 ms
Example 4: 1938 - 2063 ms
***Edit***
Closer inspection of the strlen showed that min length was 1.
New results:
Example 1: average 250 ms
Example 2: average 250 ms
Example 3: average 125 ms