Linked List Benchmark -> ListIndex() is very slow
Posted: Wed Apr 07, 2004 12:21 pm
ForEach - Next ist very handy. But if you need the current index,
you have to use ListIndex() wich is very slow in some cases.
The best choice ist For ... NextElement() .... next
Please try this code:
cya dige
you have to use ListIndex() wich is very slow in some cases.
The best choice ist For ... NextElement() .... next
Please try this code:
Code: Select all
NewList Test.s()
#MAX = 20000
Debug "-------LinkedList Benchmarking-------"
count = GetTickcount_()
For a = 1 To #MAX
AddElement( Test() )
Test() = Space(Random(255))
Next
Debug "Adding: " + Str(GetTickcount_() - count)
count = GetTickcount_()
ForEach Test()
Test() = Space(Random(255))
i = ListIndex(Test())
Next
Debug "ForEach + ListIndex " + Str(GetTickcount_() - count)
count = GetTickcount_()
ResetList( Test() )
For a = 1 To #MAX
NextElement(Test())
Test() = Space(Random(255))
Next
Debug "For Next -> " + Str(GetTickcount_() - count)
count = GetTickcount_()
For a = #MAX To 1 Step -1
PreviousElement( Test() )
Test() = Space(Random(255))
Next
Debug "For Next <- " + Str(GetTickcount_() - count)
count = GetTickcount_()
For a = 1 To #MAX
SelectElement( Test(), a )
Test() = Space(Random(255))
Next
Debug "For Next + Select " + Str(GetTickcount_() - count)
count = GetTickcount_()
ResetList( Test() )
For a = 1 To #MAX
NextElement(Test())
i = ListIndex(Test())
Test() = Space(Random(255))
Next
Debug "ForNext + ListIndex " + Str(GetTickcount_() - count)