Sitecore 8.2 was released with Microsoft Dependency Injection and with the recent release of Sitecore 8.2.1 it was finally time for me to do what I have been promising. I wanted to take an existing solution which was on production using Simple Injector (My Favorite framework), test it again the same solution but with Microsoft DI.

So here is some information:

Two sites were setup, one for Simple Injector and one for Microsoft DI

The code is exactly the same, except the DI framework has been swapped out

No other code changes were made to the code base

The solution runs on 8.2 rev. 161115 (8.2 Update-1)

The solution uses Web API calls as well and so the Web API controllers were also registered

Related

11 comments

I’m surprised that Microsoft DI is so much faster than Simple Injector. I wish there was a way to port Simple Injector’s “Verify” functionality to Microsoft DI. That’s Simple Injector’s “killer feature” in my opinion–having a check for DI misconfiguration.

Hetal, thank you. I would not say Microsoft DI is the best over the others available but in this case I am not using any complicated DI functionality so I am able to use the default DI framework bundled by Sitecore and it happens to run faster. 😉

Thanks Chris. The trick is to do it on a real solution rather than a test solution. It took me a while to get this setup and run on a production solution. I am hoping to run this again once I move it to another environment so that we can validate the results.

Interesting Post Akshay. I did wonder who would win the battle here and it’s nice to see the default DI in SC 8.2 is faster. We are using SimpleInjector on our 8.1 implementation so during the next upgrade it might be worth moving to MS DI. Thanks for taking the time to do this.

By taking a look at the performance difference between Core DI and Simple Injector in Daniel Palme’s excellent benchmark (http://www.palmmedia.de/Blog/2011/8/30/ioc-container-benchmark-performance-comparison), you’ll see that the performance difference between the two is very small (with Simple Injector being the fastest). But the real life difference between the two is so small (we’re talking micro seconds) that it doesn’t explain the big difference between the two in your results. Those containers are both so fast, that each container will probably take up less than 1% of the total time a single request takes.

The total time each container takes per requests is probably so insignificant, that I don’t believe you can draw any conclusions from your tests on which one’s the fastest. You might want to rerun your tests in a different order, on different machines multiple times over.

Thank you for commenting. I understand what you are saying but here is how I setup the tests and hopefully you can suggest how I could improve it.

– Took gold source which currently runs on prod and uses Simple Injector
– Deploy to the same IIS server and DB server which run Sitecore CMS
– One site for site running Simple Injector
– One site running Microsoft DI
– Keep in mind that, Sitecore 8.2.1 by default uses Microsoft DI for its own internal implementation.
– Only one site was running at one time
– Before each test, the server was recycled
– The same two tests were run on the two sites – three times each to get averages
– I used LoadImpact.com to run the tests

You keep quoting Daniel’s blog, which is what I used to make the decision to use Simple years ago. Since Microsoft DI is included as part of Sitecore, I decided to give it a chance. If you have any suggestions on top of this please let me know. Otherwise I am sticking to Microsoft DI and will run future tests on load balanced environments and post the results.

This is a personal blog. Any views or opinions represented in this blog are my own and do not represent those of people, institutions or organizations that the I may or may not be associated with in professional or personal capacity including past, current and future employers, unless explicitly stated.