Cor,
Please read my original post again! Read the entire post, specifically the
second paragraph!
<quote>
The reason being is the typed dataset uses a DataColumn when indexing into
the DataRow.Item property. Most untyped dataset code will use either an
Integer or the field name when indexing into the DataRow.Item property.
</quote>
Notice that I state why the typed dataset is faster (which you are free to
use) and why most untyped code is slower (which again you are free not to
use).
Again Sceppa explains how to use the same techniques as the typed dataset!
> Another question: is that QueryPerformanceCounter more accurate than the
> environment.ticks? (I can look it up however when you say so it is for me
> in
> this case).
http://support.microsoft.com/default...b;en-us;306978
Enivonment.TickCount is "the amount of time in milliseconds that has passed
since the last time the computer was started". My understanding
Environment.TickCount is calling the Win32 GetTickCount API.
The QueryPerformanceCounter is at the same resolution as the Performance
Counter classes, (nanosecond or higher).
There is also DateTime (DateTime.Ticks) which is "the number of
100-nanosecond intervals that have elapsed..."
VS.NET 2005 (aka Whidbey due out in 2005) will have a stopwatch object that
appears to use either QueryPerformanceCounter or DateTime.
http://lab.msdn.microsoft.com/librar..._Stopwatch.asp
Hope this helps
Jay
"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Jay,
>
> My point is that everything you create in a typed datases you can do with
> an
> untyped dataset. When you say that this is a wrong statement of me, than I
> can agree with you even without one single piece of code.
>
> Another question: is that QueryPerformanceCounter more accurate than the
> environment.ticks? (I can look it up however when you say so it is for me
> in
> this case).
>
> It is by the way an interesting piece of code you made, I will take some
> time today to evaluate it completly :-)
>
> Thanks,
>
> Cor
>
>> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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
>> >
>> >
>>
>>
>
>