Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq To Sql vs Entity Framework Performance

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: (dead link)

One instance of the context, multiple calls of the same sproc: (dead link)

Multiple instances of the context, multiple calls of the same sproc: (dead link)

like image 925
Vyrotek Avatar asked Nov 02 '08 16:11

Vyrotek


People also ask

Which is better Entity Framework or LINQ to SQL?

LINQ to SQL allow you to query and modify SQL Server database by using LINQ syntax. Entity framework is a great ORM shipped by Microsoft which allow you to query and modify RDBMS like SQL Server, Oracle, DB2 and MySQL etc. by using LINQ syntax. Today, EF is widely used by each and every .

Which is faster LINQ or Entity Framework?

LINQ To SQL is slow for the first time run. After first run provides acceptable performance. Entity Framework is also slow for the first run, but after first run provides slightly better performance compared to LINQ To SQL.

Is Entity Framework faster than SQL query?

Entity Framework very slow compared to SQL Query.

Is LINQ faster than SQL?

Sql is faster than Linq. Its simple: if I m executing a sql query directly its a one way process whereas if I m using linq, first its been converted to sql query and then its executed.


2 Answers

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.

like image 187
Craig Stuntz Avatar answered Oct 18 '22 20:10

Craig Stuntz


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

like image 26
Shannon Davidson Avatar answered Oct 18 '22 22:10

Shannon Davidson