*** 100,000 iterations:
ManualBenchmarkSuite starting... (this is DI by hand using a generic dictionary)
CounterLogger called 100000 times.
Elapsed Time: 332 milliseconds
AutofacBenchmarkSuite starting...
CounterLogger called 100000 times.
Elapsed Time: 613 milliseconds
NinjectBenchmarkSuite starting...
CounterLogger called 100000 times.
Elapsed Time: 1683 milliseconds
WindsorBenchmarkSuite starting...
CounterLogger called 100000 times.
Elapsed Time: 979 milliseconds
*** 1,000,000 iterations:
ManualBenchmarkSuite starting...
CounterLogger called 1000000 times..
Elapsed Time: 4417 milliseconds
AutofacBenchmarkSuite starting...
CounterLogger called 1000000 times.
Elapsed Time: 7434 milliseconds
NinjectBenchmarkSuite starting...
CounterLogger called 1000000 times.
Elapsed Time: 20653 milliseconds
WindsorBenchmarkSuite starting...
CounterLogger called 1000000 times.
Elapsed Time: 10773 milliseconds
You can see here that there is a dramatic degradation in performance
with Ninject under sustained load...this is using a singleton
lifecycle - I would expect under this scenario that the measurements
would be linear as the container should be returning the same instance
repeatedly, right? (and no - I don't have any of the interception
stuff wired in - never could get that working...) I'd be happy to send
you the code I'm using for the benchmarks, but it's pretty much by the
book, straightforward binding calls and then resolves. I also have a
warm up cycle that throws away the first request of the container, so
it's not that I'm including the container startup time in my
measurements...
Any ideas to eke some performance out of Ninject?
Thanks,
Matt
In any event, I'm regretting jumping on the "me, too" bandwagon here
and posting my findings - I didn't mean any ill will, I have the
deepest respect for what Nate's been able to accomplish with Ninject,
you, Nick, with Autofac, etc... far beyond anything I could dream of
pulling off.
Arbitrary performance benchmarks have no place here and should not be
used as the basis for picking one container over another - the
underlying mechanics are largely the same these days - choose the
container that has the features you need for your applications.
Just to make sure I understood...
what do you mean with "singleton"?