I was experimenting with lists, and I found out on my machine at least, ListRemove is about 6x faster than RemoveLink.
But I've heard to always use RemoveLink, even the documents suggests that ("RemoveLink is more efficient than ListRemove.")
I'm I missing something or is ListRemove truely faster than RemoveLink?
It doesn't really make a big difference unless if your handling tens of thousands of objects.
SuperStrict Type TObject Field Link:TLink Function Create:TObject() Local o:TObject=New TObject o.Link=ListAddLast(List,o) Return o End Function Method RemoveByLink() RemoveLink Link End Method Method RemoveByList() ListRemove List,Self End Method End Type Global List:TList=CreateList() Global maxobjects:Int=163840 PopulateList() RemoveAllByLink() PopulateList() RemoveAllByList() Function PopulateList() Local start:Int,time:Int,i:Int start=MilliSecs() For i=0 To maxobjects TObject.Create() Next time=MilliSecs()-start Print "Add To List Time: " +time+ " ms" Print "Object Count: " +CountList(List) End Function Function RemoveAllByLink() Local start:Int,time:Int,i:Int,o:TObject start=MilliSecs() For o=EachIn List o.RemoveByLink() Next time=MilliSecs()-start Print "Remove By Link Time: " +time+ " ms" Print "Object Count: " +CountList(List) End Function Function RemoveAllByList() Local start:Int,time:Int,i:Int,o:TObject start=MilliSecs() For o=EachIn List o.RemoveByList() Next time=MilliSecs()-start Print "Remove By List Time: " +time+ " ms" Print "Object Count: " +CountList(List) End Function
But I've heard to always use RemoveLink, even the documents suggests that ("RemoveLink is more efficient than ListRemove.")
I'm I missing something or is ListRemove truely faster than RemoveLink?
It doesn't really make a big difference unless if your handling tens of thousands of objects.