G
Guest
Today, after watching the presentation by Amanda Silver from Channel 9,
started exploring the LINQ features. Surprisingly, few facts unearthed to
prove that LINQ is slower, much to double the time consumed by the usage of
traditional Data Adapter. Correct me if you find these facts can be proved
fault
HW Scenario :
----------------------------------------------------------------------------
System OS - XP Prof with SP2
System Processor - AMD 3000+ with 2GHz
RAM - 1 GB
DB Server - LocalHost on SQL Server 2005
Implemented with Orcas Beta 2
----------------------------------------------------------------------------
Source Code copied from Amanda's presentation
Code Snippet for LINQ
----------------------------------------------------------------------------
Dim t1, t2 As Double
t1 = Date.Now.TimeOfDay.TotalMilliseconds
Dim db As New exLinqDataContext(My.Settings.NorthwindConnectionString)
Dim query = From cust In db.Customers _
Join sup In db.Suppliers _
On cust.City Equals sup.City _
Select cust.CompanyName, sup.ContactName, cust.City
Me.DataGridView1.DataSource = query
t2 = Date.Now.TimeOfDay.TotalMilliseconds
Dim diffT As Double
diffT = t2 - t1
MessageBox.Show(diffT)
----------------------------------------------------------------------------
Source Code using Traditional Data Adapter
----------------------------------------------------------------------------
Dim t1, t2 As Double
t1 = Date.Now.TimeOfDay.TotalMilliseconds
Dim cn As New SqlClient.SqlConnection("Data Source=localhost;Initial
Catalog=Northwind;Integrated Security=True")
Dim da As New SqlClient.SqlDataAdapter("Select
C.CompanyName,S.ContactName,C.City from Customers C,Suppliers S Where C.City
= S.City", cn)
Dim DS As New DataSet
da.Fill(DS)
GV.DataSource = DS.Tables(0)
t2 = Date.Now.TimeOfDay.TotalMilliseconds
Dim diffT As Double
diffT = t2 - t1
MessageBox.Show(diffT)
----------------------------------------------------------------------------
For your attention here comes the result for the first execution time of
each method
-------------------
LINQ DataAdapter
-------------------
171.875 93.750
171.875 93.750
156.250 78.125
156.250 78.125
156.250 78.125
started exploring the LINQ features. Surprisingly, few facts unearthed to
prove that LINQ is slower, much to double the time consumed by the usage of
traditional Data Adapter. Correct me if you find these facts can be proved
fault
HW Scenario :
----------------------------------------------------------------------------
System OS - XP Prof with SP2
System Processor - AMD 3000+ with 2GHz
RAM - 1 GB
DB Server - LocalHost on SQL Server 2005
Implemented with Orcas Beta 2
----------------------------------------------------------------------------
Source Code copied from Amanda's presentation
Code Snippet for LINQ
----------------------------------------------------------------------------
Dim t1, t2 As Double
t1 = Date.Now.TimeOfDay.TotalMilliseconds
Dim db As New exLinqDataContext(My.Settings.NorthwindConnectionString)
Dim query = From cust In db.Customers _
Join sup In db.Suppliers _
On cust.City Equals sup.City _
Select cust.CompanyName, sup.ContactName, cust.City
Me.DataGridView1.DataSource = query
t2 = Date.Now.TimeOfDay.TotalMilliseconds
Dim diffT As Double
diffT = t2 - t1
MessageBox.Show(diffT)
----------------------------------------------------------------------------
Source Code using Traditional Data Adapter
----------------------------------------------------------------------------
Dim t1, t2 As Double
t1 = Date.Now.TimeOfDay.TotalMilliseconds
Dim cn As New SqlClient.SqlConnection("Data Source=localhost;Initial
Catalog=Northwind;Integrated Security=True")
Dim da As New SqlClient.SqlDataAdapter("Select
C.CompanyName,S.ContactName,C.City from Customers C,Suppliers S Where C.City
= S.City", cn)
Dim DS As New DataSet
da.Fill(DS)
GV.DataSource = DS.Tables(0)
t2 = Date.Now.TimeOfDay.TotalMilliseconds
Dim diffT As Double
diffT = t2 - t1
MessageBox.Show(diffT)
----------------------------------------------------------------------------
For your attention here comes the result for the first execution time of
each method
-------------------
LINQ DataAdapter
-------------------
171.875 93.750
171.875 93.750
156.250 78.125
156.250 78.125
156.250 78.125