Results 1 to 4 of 4

Thread: Performance of dependency injection

  1. #1
    Join Date
    Apr 2006
    Posts
    23

    Default Performance of dependency injection

    Gday,

    I'm fairly new to Spring (used Spring for a bit in my app). One thing that I noticed is that the app runs faster without the dependency injection (i.e. without Spring).

    Is this a normal behaviour? Or is this just a misconfiguration in my Spring?
    Spring is great, but I just want to know if there are any performance impacts towards the application.


    Regards,


    Alex.

  2. #2
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    The overhead should be approximately the overhead incurred due to the usage of reflection (plus type conversion).
    However, due to the fact that IoC is mostly used for configuration, that should normally not be a big issue.

    So the questions are: How do you use Spring inside your application and how did you measure the timing?

    Regards,
    Andreas

  3. #3
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    Quote Originally Posted by netzone_tech
    Gday,

    I'm fairly new to Spring (used Spring for a bit in my app). One thing that I noticed is that the app runs faster without the dependency injection (i.e. without Spring).
    How many objects are you creating in Spring? Most objects I create in Spring are 'singletons', so only one instance is required and they are wired up in the beginning. So they only thing that causes overheads is the AOP stuff. But in most cases the communication with the outside world is much slower (your db transactions). So they would be an order of magnitude slower.

    Is this a normal behaviour? Or is this just a misconfiguration in my Spring?
    Spring is great, but I just want to know if there are any performance impacts towards the application.
    Can you tell more about your system because we don't have enough information to see what is the cause of the problem.

  4. #4
    Join Date
    Aug 2004
    Posts
    1,905

    Default

    Quote Originally Posted by netzone_tech
    I'm fairly new to Spring (used Spring for a bit in my app). One thing that I noticed is that the app runs faster without the dependency injection (i.e. without Spring).
    Can you define "faster", milliseconds, seconds etc.

    Quote Originally Posted by netzone_tech
    Is this a normal behaviour? Or is this just a misconfiguration in my Spring?
    Spring is great, but I just want to know if there are any performance impacts towards the application.
    How large is your spring context etc.? Also, quite often the perceived delay is actually in objects being created, so if you were to instantiate all the same objects manually; it would take the same time...the "spring overhead" is actually very small.

    Can you provide some figures please...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •