locked
Benchmark Entity Framework 5 RRS feed

  • Question

  • I'm following the performance test  that Dapper community created.

    Currently, I'm getting the following after run the tests 10000 times:

     - EF 5 = 21595 ms
     - ADO.NET = 52183 ms
     - Dapper = 52499 ms
     - iBatis = 83138 ms

    I need that something help me to understand why EF is faster.
    **What did I do wrong?**

    The code that I'm using is on Github
    • Edited by Augusto Pedraza Friday, September 27, 2013 3:52 PM
    • Moved by CoolDadTx Friday, September 27, 2013 4:39 PM EF related
    Friday, September 27, 2013 3:50 PM

Answers

  • Entity Framework creates optimized queries based on the dbset defined... It would be good debug to look at what is generated and compare to what you have.  The MS developers have put in a lot of time to make sure EF is efficient as possible.  :)
    • Proposed as answer by PaulDAndrea Monday, October 7, 2013 4:40 PM
    • Marked as answer by Fred Bao Tuesday, October 8, 2013 1:02 AM
    Friday, September 27, 2013 4:46 PM
  • Hi,

    From my opinion, in EF 5, the first time we execute a LINQ to Entities query EF will take the LINQ expression and compile it just like it did in EF 4. It will then store the compiled query into an internal query cache. The biggest benefit will come the second time you execute the same query since EF will now skip compilation completely and just use the compiled query it has cached.

    So I think that may be because when we use the ADO.Net, we need to send the query command to database every time, and while we use the entity framework, we just need  compile it at the first time.

    Hope it be helpful you.

    Thanks &Regards.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Fred Bao Friday, October 4, 2013 3:35 AM
    Monday, September 30, 2013 3:01 AM

All replies

  • Entity Framework creates optimized queries based on the dbset defined... It would be good debug to look at what is generated and compare to what you have.  The MS developers have put in a lot of time to make sure EF is efficient as possible.  :)
    • Proposed as answer by PaulDAndrea Monday, October 7, 2013 4:40 PM
    • Marked as answer by Fred Bao Tuesday, October 8, 2013 1:02 AM
    Friday, September 27, 2013 4:46 PM
  • Thanks for you answer.

    I know that EF is very optimazed, but I think that it resolve your LINQ creating a custom query that will be executed over ADO.net.

    So, although the EF is very efficient, it should not be faster that ADO.NET.

    Friday, September 27, 2013 5:49 PM
  • Hi,

    From my opinion, in EF 5, the first time we execute a LINQ to Entities query EF will take the LINQ expression and compile it just like it did in EF 4. It will then store the compiled query into an internal query cache. The biggest benefit will come the second time you execute the same query since EF will now skip compilation completely and just use the compiled query it has cached.

    So I think that may be because when we use the ADO.Net, we need to send the query command to database every time, and while we use the entity framework, we just need  compile it at the first time.

    Hope it be helpful you.

    Thanks &Regards.


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    • Marked as answer by Fred Bao Friday, October 4, 2013 3:35 AM
    Monday, September 30, 2013 3:01 AM