BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
There are a bewildering array (excuse the pun) of data storage structures available to you in Visual Basic. Choose from arrays, ArrayLists, SortedLists, Dictionaries, HashTables, Lists and DataTables, among others. This blog gives an example of each type of structure, and benchmarks them to show which perform best and worst.
- VB.NET Data Storage Types Compared and Benchmarked
- VB.NET Benchmarking Test of speeds of data structures
- Arrays - Visual Basic data structures
- ArrayLists and SortedLists - Visual Basic data structures
- Dictionaries and HashTables - Visual Basic data structures
- Lists - Visual Basic data structures (this blog)
- Using data tables - Visual Basic data structures
- Benchmark Results and Recommendations
Posted by Andy Brown on 24 August 2011
You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.
Lists
A list is just a collection to which you can add items easily. The code I used to test list performance is as follows:
Sub TestList()
Dim list As New List(Of String)
StartTimer()
'first test: writing 10 ^ n values
Dim i As Integer
For i = 0 To (10 ^ RunSize) - 1
list.Add(TestCode(i))
Next
'work out how long this took
WriteTime = ElapsedTime
'store ten values for subsequent tests
StoreTenValues()
'sort the list (timing this)
list.Sort()
SortTime = ElapsedTime
'third test: find 10 "random" values by number
Dim s As String
For i = (10 ^ RunSize) - 1 To 0 Step -(10 ^ (RunSize - 1))
s = list(i)
Next
'report how long this took
Read1Time = ElapsedTime
'fourth test: find 10 "random" values by name
For i = 0 To 9
s = TextValues(i)
For j = 0 To (10 ^ RunSize) - 1
If list(j) = s Then
Exit For
End If
Next
Next
Read2Time = ElapsedTime
'write out results of test
AddRow("List")
End Sub
The results of running this test are shown at the end of this blog.
- VB.NET Data Storage Types Compared and Benchmarked
- VB.NET Benchmarking Test of speeds of data structures
- Arrays - Visual Basic data structures
- ArrayLists and SortedLists - Visual Basic data structures
- Dictionaries and HashTables - Visual Basic data structures
- Lists - Visual Basic data structures (this blog)
- Using data tables - Visual Basic data structures
- Benchmark Results and Recommendations