Hi all,
In a case where you would like to reset an array of boolean values what is faster, rediming the array or enumerating and resetting the values?
I have run some tests and they seem to suggest that a redim is a lot faster but I am not convinced that it isnt a result of how I’m running the tests.
My tests seem to suggest that redim is nearly twice as fast.
So could anyone care to comment on which is faster and why? Also would you expect the same result across different languages?
Enum Test:
Dim booleanArray(200) As Boolean
Dim startTime As Date = Date.Now
For i As Integer = 0 To 9999999
For l As Integer = 0 To 200
booleanArray(l) = True
Next
Next
Dim endTime As Date = Date.Now
Dim timeTaken As TimeSpan = endTime - startTime
Redim Test:
Dim booleanArray(200) As Boolean
Dim startTime As Date = Date.Now
For i As Integer = 0 To 9999999
ReDim booleanArray(200)
Next
Dim endTime As Date = Date.Now
Dim timeTaken As TimeSpan = endTime - startTime