Entity Framework 4.1 vs Enterprise Application Application Maximum Maximum Performance

Problem: I want to use EF4.1 without any compromise with the speed and reliability of the Enterprise Library A data access unit that I know and trust.

Thanks to the many Stackoverflow links and EF performance tuning blogs, I am posting this path among many to use EF4.1, which corresponds to the performance of the ADO / Enterprise Lib data access block (SqlDataReader).

Project: 1. No linq for Entities / dynamic sql. I like linq, I'm just trying to use it mainly for objects. 2. 100% stored procedures and no tracking, no merging, and most importantly, never call .SaveChanges (). I just call the insert / update / delete method DbContext.StoredProcName (params). At this point, we excluded some quick Dev EF elements, but the way it automatically creates a complex type for your stored procedure is enough for me.

SqlTableRow countThe classThe mapper GetString and similar methods are AbstractMapper, which simply goes through the expected types and drops the datareader into the type. The sprocEnterprise lib result

So this is the sign that struck me. It would be difficult to accept what I know to be slower.

EF result one

This is SLOWER !!! Much slower!

EF Result TWO

I like it more! Performance Pie Based on my results, pie performance should increase tracking overhead by much more than 1%. I tried precompiling the views and nothing got as much as tracking! What for?? Maybe someone can talk about it.

So, it is not very fair to compare with Enterprise Lib, but I make one raw call to the database to load metadata, which, as I understand it, is loaded once into the IIS application pool. In fact, once in the life of your application.

EF result Three

I use EF in this way with the creation of an automatic stored procedure, and I used Linq for Edmx to automatically import all these functions to edmx nodes to map to objects. Then I automatically create a repository for each object and engine.

Since I never call SaveChanges, I do not take the time to match the saved procs in the designer. It takes too much time, and this is a way to easily break it and not know. So I just call procs from the context.

Before I actually implement this in my new web-based application for delivering health information about essential health services, I would appreciate any comments or criticisms.

Thanks!

+5
source share
1 answer

Just a few comments:

Performance Pie Based on my results, increasing tracking overhead is much more than 1%. I tried before compiling the views, and nothing became as big as tracking! Why??

Blog post since 2008 and therefore based on EF version 1 and EntityObject derived entities. With EF 4.1 you use POCOs. Tracking changes behaves differently with POCOs. Especially when a POCO object is loaded from the database into the object context. The Entity Framework takes a snapshot of the original property values, and stores in context. Tracking changes depends on a comparison between the current entity values ​​and the values ​​of the original snapshot. Creating this snapshot appears to be costly in terms of performance and memory consumption. My observations are that it costs at least 50 percent (the request time without tracking changes is half the time of the request with change tracking). You seem to have measured even greater effect.

Project: 1. No linq for Entities / dynamic sql. I love linq, I just try to use it mostly against objects. 2. 100% stored procedures and no tracking, no merging, and most importantly, never call .SaveChanges (). I just call the insert / update / delete procedure DbContext.StoredProcName (PARAMS). At this point, we have eliminated some of the fast-growing elements of EF, but the way it automatically creates a complex type for your stored procedure is enough for me.

To me, it seems like you are ignoring, in fact, some of the basic functions that exist in the Entity Framework, and cast doubt on why you want to use EF for your purpose in general. If your main goal is to have a tool that helps to materialize query results into complex objects, you can take a look at Dapper , which focuses on this task with high performance. (Dapper is the primary ORM used here in Stackoverflow.)

A few days ago there was a question with great answers about EF performance. Now it has been ported to "Programmers":

https://softwareengineering.stackexchange.com/questions/117357/is-entity-framework-suitable-for-high-traffic-websites

+5
source

All Articles