What performance overhead do IoC containers involve?

后端 未结 3 1701
暖寄归人
暖寄归人 2021-02-06 06:25

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 coupl

3条回答
  •  别跟我提以往
    2021-02-06 06:49

    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.

提交回复
热议问题