Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What performance overhead do IoC containers involve?

Loose coupling is wonderful of course, but I have often wondered what overhead wiring up dynamically using an IoC container (for example Castle Windsor) has over a tightly coupled system?

I know that a detailed answer would depend on what the IoC was being used for, but I'm really just trying to get a feel for the magnitude of effort involved in the IoC work.

Does anyone have any stats or other resources regarding this?

Thanks

like image 746
UpTheCreek Avatar asked Feb 04 '23 08:02

UpTheCreek


1 Answers

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

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

But as you can see the Windsor isnt the fastest IoC (Autofac much faster)

The correct answer is, the performance doesn't matter :).
Because the correct using of IoC ,when all registering process is at initializing stage.
In other words the using of IoC must reducing the count of your "if else" in real-time.

like image 58
Avram Avatar answered Feb 15 '23 07:02

Avram