Code: Select all
HowManyTimes = 10000
HowManyIndexes = 10000
StartTimer(1)
For n = 1 To HowManyTimes
Testi = CreateList()
For n = 1 To HowManyIndexes
InsertItem(Testi, {distance=200})
Next
Next
CreateList = GetTimer(1)
StartTimer(2)
For n = 1 To HowManyTimes
testi = {}
For n = 1 To HowManyIndexes
testi[n] = {distance=200}
Next
Next
RegularTable = GetTimer(2)
StartTimer(3)
For n = 1 To HowManyTimes
Testi = CopyTable(Testi)
Next
CopyTbl = GetTimer(3)
DebugPrint("CreateList:"..CreateList.." RegularTable:"..RegularTable.." CopyTable:"..CopyTbl)
CreateList: 6
RegularTable: 3
CopyTable: 18648
Tested on Hollywood 11, Windows 11.
This also brings a question, as CreateList lists are supposed to be fastest, and I have noticed in other of my tests too, that often using Table[n] = x, is faster than using CreateList possibilities, is this because I am using windows, or is this true on Amiga too? For I am especially trying to optimize my code to work faster on AOS4 machines, hence this info would be valuable, especially since for example in this examples case, using Talbe[n] = x to create the table, was double the speed compared to using CreateList with InsertItem.
And especially surprising was how much slower CopyTable option was, which is completely in different league.