So I did these preliminary tests using a 2.6MB text file with 240000 entries length 2 to 20, selecting the 13,000 + entries of length 5.
1-3 used System.IO.File.ReadAllLines to populate array (words), 4 -5 used this streaming function ...
1)
2)
3)
4)
5)
6)
I'll give a little while for people to stick their necks out and air their pet theories on which test did best in terms of speed, CPU load, and memory consumption and then I'll reveal the results.
At some point I'll do similar tests with rather more complex search criteria.
1-3 used System.IO.File.ReadAllLines to populate array (words), 4 -5 used this streaming function ...
vb.net Code:
Public Iterator Function StreamAllLines(path As String) As IEnumerable(Of String) Using fileStream = New System.IO.StreamReader(path) Dim line As String = fileStream.ReadLine() Do While line <> Nothing Yield line line = fileStream.ReadLine() Loop End Using End Function
1)
vb.net Code:
For Each l In words If l.Length = 5 Then lst.Add(l) Next
2)
vb.net Code:
lst = (From x In words Where x.Length = 5).ToList
3)
vb.net Code:
lst = Array.FindAll(words, (Function(x) x.Length = 5)).ToList
4)
vb.net Code:
For Each l In StreamAllLines(filename) If l.Length = 5 Then lst.Add(l) Next
5)
vb.net Code:
lst = (From x In StreamAllLines(filename) Where x.Length = 5).ToList
6)
vb.net Code:
lst = Array.FindAll(StreamAllLines(filename).ToArray, (Function(x) x.Length = 5)).ToList
I'll give a little while for people to stick their necks out and air their pet theories on which test did best in terms of speed, CPU load, and memory consumption and then I'll reveal the results.
At some point I'll do similar tests with rather more complex search criteria.