I think your tests have a flaw as they are including the Container.Build for every iteration.
If you are doing the tests with the FieldInjections Demo you need to extract the GlobalContainer.Build call from the DoOrderProcessing routine if you are calling that one in a loop.
100.000 calls take approx 3 seconds then here.
That is a huge difference to your numbers.
But I am not saying there is no room to improve performance. You are welcome to examine further.
--
You received this message because you are subscribed to the Google Groups "Spring Framework for Delphi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spring4d+u...@googlegroups.com.
To post to this group, send email to spri...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msg/spring4d/-/sZz_LO7GNYoJ.
For more options, visit https://groups.google.com/groups/opt_out.
“The framework is threadsafe?”
No and that is (from a first look) at least because the TDependencyResolver uses a list to detect circular references which does not work in multithreading.
Von: spri...@googlegroups.com [mailto:spri...@googlegroups.com]
Im Auftrag von Roberto Schneiders
Gesendet: Donnerstag, 9. Mai 2013 14:33
An: spri...@googlegroups.com
Betreff: [spring4d] Speaking a bit about performance
I'm studying this framework. I am interested in dependency injection.
--
--
You received this message because you are subscribed to a topic in the Google Groups "Spring Framework for Delphi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/spring4d/kByR7gyPMkk/unsubscribe?hl=en-US.
To unsubscribe from this group and all its topics, send an email to spring4d+u...@googlegroups.com.
Also keep in mind that in this example all components are registered as transient.
You will notice a huge performance increase when you change that to a singleton or pooled (pooled seems to be a bit broken currently, will investigate) registration for one or more components which might be the case in a server.
Resolving will definitely fail in a multithreading environment at the moment because the TDependencyResolver instance
which is part of the container adds and removes types during the process of resolving to prevent circular references and is not guarded by a CS.
I don’t know if a CS or different dependency resolver per thread is the better solution here.
Also I am not sure if TSingletonPerThreadLifetimeManager currently leaks memory as it does not remove the instance once the thread ends.
You see I am no expert in multithreading ;)
I just committed a fix for multithreading and using AsPooled.
Using the FieldInjection project:
Executions (per thread): 100000
Threads: 4
Registration: AsPooled(4, 4);
Duration: ~2000ms
As far as I can tell the resolving part it is thread safe.