C# 3.0 in a Nutshell
C# 3.0 in a Nutshell, Third Edition A Desktop Quick Reference By Joseph Albahari, Ben Albahari
September 2007
Pages: 858


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Disable Sql, Lambda And Il For Performance Testing
rekna
post Jun 22 2009, 02:27 PM
Post #1


Active Member
**

Group: Members
Posts: 17
Joined: 20-March 08
Member No.: 158



Is it possible to disable output for lamba, SQL and IL panels. I would like to test performance of Linq queries using Linqpad, but I guess output for these panels might interfere with performance measurements...
Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jun 22 2009, 04:22 PM
Post #2


Advanced Member
******

Group: Members
Posts: 203
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



Hi there

The SQL tab is fairly minimal in its overhead - I don't think it will make any difference to your performance stats.

The lamdba tab is populated (along with the results tab) only when you dump query results. When performance testing, you shouldn't dump queries because this will incur some overhead - instead, call ToArray() on them or enumerate them without writing anything.

Finally, the IL tab is populated only when you click it. So there's zero overhead there.

Regards

Joe
Go to the top of the page
 
+Quote Post
rekna
post Jun 22 2009, 10:58 PM
Post #3


Active Member
**

Group: Members
Posts: 17
Joined: 20-March 08
Member No.: 158



In one of my tests, I compare the results of 2 queries in one script, something like:

for( int i=0; i<1000; i++)
{
var q = <query1>.ToList();
}

for (int i=0; i<1000;i++)
{
var q2 = <query2>.ToList();
}

I used Stopwatch to measure time. Depending on which query was put first in code, the first one consistently run faster.

QUOTE (JoeAlbahari @ Jun 23 2009, 01:22 AM) *
Hi there

The SQL tab is fairly minimal in its overhead - I don't think it will make any difference to your performance stats.

The lamdba tab is populated (along with the results tab) only when you dump query results. When performance testing, you shouldn't dump queries because this will incur some overhead - instead, call ToArray() on them or enumerate them without writing anything.

Finally, the IL tab is populated only when you click it. So there's zero overhead there.

Regards

Joe

Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jun 24 2009, 03:31 AM
Post #4


Advanced Member
******

Group: Members
Posts: 203
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



Do you get the same results in Visual Studio?

I'd expect the opposite - the first query that you run often takes the longest for a number of reasons. One being that it's incurring the cost of building the metamodel.

Joe

This post has been edited by JoeAlbahari: Jun 24 2009, 03:32 AM
Go to the top of the page
 
+Quote Post
rekna
post Jun 25 2009, 01:53 PM
Post #5


Active Member
**

Group: Members
Posts: 17
Joined: 20-March 08
Member No.: 158



Didn't try it in Visual Studio.. could it be, because of the SQL pane is building a string with all SQL statements, and the longer it gets, the more time it needs to add ? Easiest way to know for sure would be to be able to disable those panes, and see what happens.
Go to the top of the page
 
+Quote Post
JoeAlbahari
post Jun 25 2009, 06:32 PM
Post #6


Advanced Member
******

Group: Members
Posts: 203
Joined: 15-February 08
From: Perth, Australia
Member No.: 90



I've made a preview build that lets you test this by theory by disabling the SQL translations. You can download it here:

www.linqpad.net/preview/LINQPad.exe

Then enter the following into your query before doing anything else:

LINQPad.ExecutionEngine.SqlTranslationsEnabled = true;

Joe
Go to the top of the page
 
+Quote Post
rekna
post Jul 7 2009, 10:36 PM
Post #7


Active Member
**

Group: Members
Posts: 17
Joined: 20-March 08
Member No.: 158



Finally had the time to test it, and it looks good...
I now get consistent results...
Thank you very much!!

QUOTE (JoeAlbahari @ Jun 26 2009, 03:32 AM) *
I've made a preview build that lets you test this by theory by disabling the SQL translations. You can download it here:

www.linqpad.net/preview/LINQPad.exe

Then enter the following into your query before doing anything else:

LINQPad.ExecutionEngine.SqlTranslationsEnabled = true;

Joe

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 7th November 2009 - 03:56 PM