views:

5734

answers:

3

I have been searching for recent performance benchmarks that compare L2S and EF and couldnt find any that tested calling stored procedures using the released version of EF. So, I ran some of my own tests and found some interesting results.

Do these results look right? Should I be testing it in a different way?

One instance of the context, one call of the sproc: www.vyrotek.com/code/linq1.png

One instance of the context, multiple calls of the same sproc: www.vyrotek.com/code/linq2.png

Multiple instances of the context, multiple calls of the same sproc: www.vyrotek.com/code/linq3.png

+1  A: 

I think you should test it in a somewhat different way, in order to distinguish startup costs vs. execution costs. The Entity Framework, in particular, has substantial startup costs resulting from the need to compile database views (although you can do this in advance). Likewise, LINQ has a notion of a compiled query, which would be appropriate if executing a query multiple times.

For many applications, query execution costs will be more important than startup costs. For some, the opposite may be true. Since the performance characteristics of these are different, I think it's important to distinguish them. In particular, averaging startup costs into the average cost of a query executed repeatedly is misleading.

Craig Stuntz
But wouldnt these results reflect how things would work in an asp.net application? Since I cant really keep an instance either context 'alive' I have to make a new one on every request and call the stored procedure.
Vyrotek
Craig Stuntz
A: 

I did a couple of test asp.net pages trying to see which performs better. My test was:

Delete 10,000 records Insert 10,000 records Edit 10,000 records Databind the 10,000 records to a GridView and display on the page

I was expecting LinqToSQL to be faster but doing the above LinqToSQL takes nearly 2 minutes while LinqToEntities takes less than 20 seconds.

At least for this test it seems LinqToEntities is faster. My results seem to match yours as well.

I didn't try Inserting/Editing/Deleting/Displaying more than 1 table joined together though.

I'm interested in finding out more... or if my test isn't a valid type of test I'd be interested in seeing some real tests.

metanaito
A: 

This looks to be a pretty measurement of performance between LINQ to SQL and Entity Framework.

http://toomanylayers.blogspot.com/2009/01/entity-framework-and-linq-to-sql.html

Shannon Davidson