Cor,
Seeing as Sceppa's statement was based on a beta I put together the
following test, hopefully I did it right ;-)
Public Class DataSetTiming
Private Delegate Sub Test(ByVal row As DataRow, ByVal column As
DataColumn)
Declare Function QueryPerformanceCounter Lib "Kernel32" (ByRef X As
Long) As Short
Declare Function QueryPerformanceFrequency Lib "Kernel32" (ByRef X As
Long) As Short
Public Shared Sub Main()
Dim table As DataTable = CreateTable()
PopulateTable(table)
For index As Integer = 1 To 10
Debug.WriteLine(index, "test")
Debug.Indent()
RunTest("Integer", AddressOf IntegerIndex, table)
RunTest("String", AddressOf StringIndex, table)
RunTest("Column", AddressOf ColumnIndex, table)
Debug.Unindent()
Debug.WriteLine(Nothing)
Next
End Sub
Private Shared Function CreateTable() As DataTable
Dim table As New DataTable("Test")
table.Columns.Add("id", GetType(Integer))
table.Columns.Add("name", GetType(String))
table.Columns.Add("value", GetType(Decimal))
With table.Columns("id")
.AutoIncrement = True
.AutoIncrementSeed = -1
.AutoIncrementStep = -1
End With
Return table
End Function
Private Shared Sub PopulateTable(ByVal table As DataTable)
Dim rand As New Random
For index As Integer = 0 To 100000
table.Rows.Add(New Object() {Nothing, String.Format("V{0}",
index), rand.Next(1, 1000)})
Next
End Sub
Private Shared Sub RunTest(ByVal category As String, ByVal test As Test,
ByVal table As DataTable)
Dim start, finish, frequency As Long
QueryPerformanceCounter(start)
Dim column As DataColumn = table.Columns("value")
For Each row As DataRow In table.Rows
test(row, column)
Next
QueryPerformanceCounter(finish)
QueryPerformanceFrequency(frequency)
Debug.WriteLine((finish - start) / frequency, category)
End Sub
Private Shared Sub IntegerIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row(2) = DirectCast(row(2), Decimal) * 1.1D
End Sub
Private Shared Sub StringIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row("value") = DirectCast(row("value"), Decimal) * 1.1D
End Sub
Private Shared Sub ColumnIndex(ByVal row As DataRow, ByVal column As
DataColumn)
row(column) = DirectCast(row(column), Decimal) * 1.1D
End Sub
End Class
Running 10 sets I get the following:
test: 1
Integer: 1.3314144674812
String: 1.29888407604877
Column: 1.06492529078416
test: 2
Integer: 1.10235853998204
String: 1.32747067015501
Column: 1.0537758290509
test: 3
Integer: 1.0954998470476
String: 1.33955460819741
Column: 1.06967896757828
test: 4
Integer: 1.12571150802686
String: 1.33948337009313
Column: 1.05996264888415
test: 5
Integer: 1.15852098520901
String: 1.32627694301929
Column: 1.066469621139
test: 6
Integer: 1.15292222894251
String: 1.36355626203889
Column: 1.1006843048488
test: 7
Integer: 1.14156352273823
String: 1.33735544601339
Column: 1.08128267698828
test: 8
Integer: 1.14533830416994
String: 1.33989096379568
Column: 1.08176709609741
test: 9
Integer: 1.13144491827872
String: 1.38126968651044
Column: 1.11549261149113
test: 10
Integer: 1.17510465715615
String: 1.35280657178496
Column: 1.10689766436796
Which shows that indexing DataRow by DataColumn is quicker, however not by
much. indexing DataRow by String is clearly slower...
Hope this helps
Jay
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Jay,
Using a typed dataset will probably be faster then using an untyped
dataset.
Why when I use exactly the same code as is use to make a typed dataset to
access my untyped dataset directly.
I can understand your statetement, when you say: "a typed dataset is
mostly
made with more eye for efficiency". However when it is as my first
sentence,
I don't see it.
Cor