ok, I originally said in my msg 2 above that looping through a simple embeded list will be "faster" than an array. Since I hadn't tested it I decided to replace that claim with "as fast as". I though it would be faster since the loop would not have to do any pointer arithmetic. the following example seems to show that looping through the list is faster.
anybody see any problems with the above code?
when running, click run from the ide a bunch to get a feel for the timing.
[edit] changed code to put prints at bottom... didn't see a change though on my machine.
SuperStrict Framework BRL.GLMax2D Import BRL.Random Import BRL.StandardIO Type TPart Global livePartList:TPart Global livePartArray:TPart[] Global total:Int Field nextPart:TPart Field one:Int Field two:Int Function Create( total:Int=100 ) livePartArray = New TPart[total] For Local i:Int = 0 Until total Local p:TPart = New TPart p.one = Rnd(10000) livePartArray[i] = p p.nextPart = livePartList livePartList = p Next TPart.total = total End Function Function LoopList() Local p:Tpart = livePartList While p p.one = 99 p = p.nextPart Wend End Function Function LoopArray() For Local p:TPart = EachIn livePartArray p.one = 99 Next ' For Local i:Int = 0 Until total ' livePartArray[i].one = 99 ' Next End Function End Type TPart.Create(1000000) Local times:Int[3] GCSetMode 2 Delay(100) Local time:Int=MilliSecs() TPart.LoopList times[0] = MilliSecs()-time time:Int=MilliSecs() TPart.LoopArray times[1] = MilliSecs()-time time:Int=MilliSecs() TPart.LoopList times[2] = MilliSecs()-time Print "~nLivePartList: "+times[0]+"ms" Print "~nLivePartArray: "+times[1]+"ms" Print "~nLivePartList: "+times[2]+"ms"
anybody see any problems with the above code?
when running, click run from the ide a bunch to get a feel for the timing.
[edit] changed code to put prints at bottom... didn't see a change though on my machine.