Note: before reading this article please see my views on comparing ORM tools. In short: this comparison is not suitable for comparing NHibernate and Entity Framework, due to the complexity of the tools vs the simplicity of this test; treat this post accordingly.
The reason I’m revising previous results is because some members of the NHibernate community looked into the code and discovered that the comparison wasn’t totally fair. While the test cases with Entity Framework used batch operations, the NHibernate implementation had this feature turned off. Tuna Toksoz was kind enough to re-write the critical parts of the code and apply settings enabling batching, you can download the revised source code here.
Note that I’ve made the source open for two reasons. First, I’d like the tests to be reproducible. And more importantly: I have experience with the two frameworks however I’m not an expert at any of them: therefore treat the results with caution. Anyone is free to analyze the source and if there are some issues in the code resulting in major performance drops, please let me know.
After Tuna modified the code NHibernate storage speed rocketed up compared to the previous version:
|Framework/ No. of operations||1K||3K||8K||14 K||23K||33K||40K|
As I’ve stated before I don’t beleive there is a good way in comparing ORM frameworks and even if there were, this little test certanly is not it.
As the contribution of the NHibernate community members showed the more complex and configurable the tool, the more experience you’ll need to make the best of this. If you’re working on a performance critical product, you’d better know you’re tool well and use it accordingly.
But which one should I use?
From the current results it seems that there is no major performance difference between two tools and even if there is it might be due to misuse. So my advice is to use which ever tool suits you more based on its features.
At first glance Entity Framework seems to have a shorter learning curve as well as some nice integrated VS tools to make development easier. On the other hand there is a constantly active and helping NHibernate community always ready to answer questions and NHibernate seems to be much more customizable at a higher level. Also see this thread on EF vs NH features and learning as well to help decide.
The decision is up to you which one you find more suitable for your needs. However since both are proven and mature solutions you won’t be making a big mistake going with which either.