Consider the following code:
Dim arr1 As New List(Of Double) Dim arr2 As New List(Of Object) Dim timeStart As DateTime = Now For x As Integer = 0 To 1000000 arr1.Add(3.14159) Next Dim timeEnd As DateTime = Now MsgBox(((timeEnd - timeStart).Seconds).ToString()) timeStart = Now arr2.Add(New List(Of Double)) For x As Integer = 0 To 1000000 arr2(0).add(3.14159) Next timeEnd = Now MsgBox(((timeEnd - timeStart).Seconds).ToString())
It includes 2 lists. The first is one-dimensional, the second is two-dimensional.
The first procedure (which works in the first list) completes in about 0.015 seconds. The second procedure (which works in the second list), however, takes almost 10 seconds. The only difference is that the second list is 2-dimensional.
Am I missing something? Is there a way to speed this up or am I doing something wrong? I have a program that requires several two-dimensional arrays, and now it works very slowly. How can I speed it up to get the same reviews as me if the lists were one-dimensional?
source share