What overhead do IoC containers use?

A reasonable connection is, of course, wonderful, but I often wondered that dynamic wiring up using an IoC container (like Castle Windsor) has a denser system?

I know that a detailed answer will depend on what IoC was used for, but I'm just trying to understand what efforts are being put into working with IoC.

Does anyone have statistics or other resources on this?

thanks

+7
performance design-patterns inversion-of-control
source share
3 answers

There are links about performance
http://realfiction.net/?q=node/143
results

  • Normal Design: 0.0001 / 0.0002
  • Activator Design: 0.0069 / 0.0071
  • Container construction (Windsor Castle): 0.1014 / 0.1068
  • Container construction (Spring.NET): 0.069 / 0.0722

But as you can see, Windsor is not the fastest IoC (Autofac is much faster)

The correct answer: performance does not matter :). Because the correct use of IoC when the entire registration process is at the initialization stage.
In other words, using IoC should reduce the number of your "if else" in real time.

+9
source share

You will have a slower initialization time, since everything loads when the container starts. If the initialization time does not matter to you, everyone wins on this wheel with a cup of luck.

+1
source share

The best way to understand how complex an IoC container comes from analyzing it.

In some specific experience, when I spent the whole day debugging some simple Hello World code using plexus , which is Maven based on ( and here is a useful link for viewing the source code ). This came up (by looking at defaultPlexusContainer) as:

  • Class Configuration (via classworlds)
  • Creating a run-time context variable (mainly a map) to store properties and variables
  • Configuration analysis (detection of module metadata on the way to classes, etc.)
  • Initialization:
    • Building / Creating Services
  • Dismissal of additional ComponentDiscoverers
  • Dismissal of additional ComponentDiscovererListeners

This leaves an important aspect, deep in the above steps: component search. In the plexus, the concept of phase wraps up the steps for building an object, and these phases are usually associated with the concept of personality. However, for the default parameter , this is done by performing the following steps:

  • Object activation (i.e. new object ())
  • Enabling the log (i.e. setting the registrar for the object)
  • Composition: i.e. dependency search and customization
    • The setter strategy is an interesting point, but for now I will leave the details
  • Passing Context to the Created Object
  • Additional object launch procedure

Most of these steps are optional and usually include the identification of this interface and calling it on the target object - this is the default value for the plexus personality, please note that.

In addition, each object can be tied to a life cycle manager, which basically makes the difference between a new object and a single.

In my specific entry: the hardest part is parsing the configuration and loading the container. After that, you most likely will not notice further differences in performance.

+1
source share

All Articles