views:

184

answers:

3

I want to start working on a big project. I research about performance issues about LINQ to EF and NHibernate. I want to use one of them as ORM in my project. now my question is that which one of these two ORM can get me better performance in my project? I will use SQL Server 2008 as database and C# as programming language.

+3  A: 

We're currently using Fluent NHibernate on one our projects (with web services, so that adds additional time lag) and as far as I can see, data access is pretty much instantaneous (from human perspective).

Maybe someone can provide answer with concrete numbers though.

Since these two ORMs are somewhat different, it'd be better to decide on which one to use with regard to your specific needs, rather than performance (which, like I said, shouldn't be a big deal).

VexXtreme
+2  A: 

Here's a nice benchmark. As you can see results depend on whether you are doing SELECT, UPDATE, DELETE.

Darin Dimitrov
1) This benchmark doesn't use explicit transactions witch has an impact on perforance2) HNibernate automatically tracks changes in session and will perform a dirty check for each entity in the session before each flush (witch explains save/update performance)3) You will have performance problems with any ORM if are a beginer (SELECT N+1 for instance)
Catalin DICU
This banchmark doesn't check a real-life scenarion, but tests batch performance. The performance numbers in a real application will be different than in a batching scenario.
Paco
+4  A: 

Neither one will have "better performance."

When analyzing performance, you need to look at the limiting factor. The limiting factor in this case will not be the ORM you choose, but rather how you use that tool, how you write your queries, and how you optimize the database backend.

Therefore, the "fastest" ORM will be the one which you can use correctly, coupled with the database server you best understand.

The ORM itself does have a certain amount of overhead, so the "fastest", in terms of sheer performance, is to use none at all. However, this favors the computer's time over at your development time, which is typically not a good trade-off. ORMs can save large amounts of your development time, while imposing only a small overhead when used correctly.

Typically when people experience performance problems when using an ORM it is because they are using the ORM incorrectly, rather than because they picked the "wrong" ORM.

Craig Stuntz
@Craig: Thanks for your answer but you suppose that every terms be equal. in this situation we can compare these two approach with each other. which one is better in same situation?
masoud ramezani
No, I didn't say they're the same. I said that the principal difference will be how you use them, rather than how they're implemented. EF and NH require very different usage patterns. Your understanding of the tool will have much to do with the performance you get out of it. I know that it can be hard for a programmer to accept that the limiting factor will be the programmer rather than the tool, but that is often the case. :)
Craig Stuntz
Thanks Craig ;)
masoud ramezani