views:

386

answers:

1

I recently was asked to troubleshoot some performance problems in an application built with Microsoft's Composite UI Application block - specifically that it was taking too long to load.

This is built around Microsoft's ObjectBuilder dependency injection framework, which uses reflection/attributes to register classes. Profiling indicated that on startup the app was spending a significant chunk of time doing reflection, as ObjectBuilder scans every type in every loaded assembly in it's search for things to register.

Alternative DI frameworks all seem to also use attributes, XML configuration, or pure code.
It doesn't seem like any of the other attribute-based frameworks would be any better, and I'm skeptical about startup times when piles of XML have to be parsed, etc too.
The pure code based frameworks seem like they should be much faster, but then they're also much less flexible, so it doesn't really seem like there's a clear good choice...

This led me to search for DI container benchmarks, but the only one I was able to find is this one: http://www.codinginstinct.com/2008/04/ioc-container-benchmark-unity-windsor.html.
While it's a great benchmark, it only measures how quickly you can create 1 million objects using the container. I have no interest in creating 1 million objects, I just want the app to launch as quickly as possible, so what I'm looking for is any information about DI Container startup costs, whether it be blog posts, anecdotes, or even something as simple as "here's a way of making ObjectBuilder faster".

Thanks in advance

+3  A: 

Have you tried measuring startup times when all the assemblies has been NGEN'd? I have found (at least in IronScheme), that it helps a lot (in my case from 1.5 secs to 0.1 secs) in reflection scenarios.

leppie
agreed, a lot of the time is due to JIT of each class.
Tom Anderson
As far as I've seen, NGen has a negligible effect on reflection performance, which is the source of this slowdown.
Bevan
I haven't tried NGEN, but I'm unsure as to whether it would be a good idea - the application in question is a ClickOnce deployed client app, and don't things have to go in the GAC to be NGEN'ed ?
Orion Edwards