IIRC,We saw something like that previously, I think that there is an O(N)
operation in Windsor somewhere.

On Wed, Sep 16, 2009 at 7:19 AM, Tyler Burd <[email protected]> wrote:

>  Hi all,
>
>
>
> I’ve got a large application that takes about 1 minute to start up.  I
> investigated today what could be the cause of this very long delay, and
> narrowed it down to the WindsorContainer.AddComponent method.  I have about
> 1000 service classes, each with an interface (the service type).  The
> average time to call WindsorContainer.AddComponent is 52ms on my system.
> 52ms * 1000 is 52 seconds, which is the vast majority of the app’s startup
> time.
>
>
>
> My system is a Quad Core, 2.66GHz Core2 running Windows XP.  The same
> approximate startup time can be verified on multiple machines, servers, and
> OS’s.
>
>
>
> Is this normal?  Do I have to just bite the bullet on a long startup time,
> or is there something I can do to help this?
>
>
>
> Here is the block of code in a small executable I used to calculate the
> times.  I can provide a profile report if necessary.  I normally use
> AllTypes along with the fluent registration, but I wanted to get as
> low-level as possible.  This code outputs:
>
>
> “Called AddComponent 957 times.  Average AddComponent time: 
> 52.0267175572519ms”
>
>
>
>
>
> *var* container = *new* WindsorContainer();
>
>
>
> //calculates the time for each AddComponent call
>
> *var* watch = *new* Stopwatch();
>
>
>
> *var* totalAddComponentCalls = 0;
>
>
>
> //keeps track of the average ms to call AddComponent
>
> *var* allAddComponentTimes = *new* List<*long*>(1000);
>
>
>
> *foreach* (*var* classType *in* *typeof*
> (TheBigApplicationThingyWithAllTheServices).Assembly.GetTypes())
>
> {
>
>                 *if* (classType.IsInterface)
>
>                                 *continue*;
>
>                 *if* (classType.Namespace == *null*)
>
>                                 *continue*;
>
>                 *if* (!classType.Namespace.Contains("Services"))
>
>                                 *continue*;
>
>                 *var* interfaces = classType.GetInterfaces();
>
>                 *if* (interfaces.Length == 0)
>
>                                 *continue*;
>
>                 *var* firstInterface = interfaces[0];
>
>
>
>                 *var* serviceName = totalAddComponentCalls.ToString();
> //simple way to get unique name
>
>                 watch.Start();
>
>                 container.AddComponent(serviceName, firstInterface,
> classType);
>
>                 watch.Stop();
>
>                 allAddComponentTimes.Add(watch.ElapsedMilliseconds);
>
>                 watch.Reset();
>
>                 ++totalAddComponentCalls;
>
> }
>
>
>
> *var* avgAddCompTime = (*from* ms *in* allAddComponentTimes 
> *select*ms).Average();
>
> Console.Out.WriteLine(*string*.Format("Called AddComponent {0} times.
> Average AddComponent time: {1}ms", totalAddComponentCalls, avgAddCompTime));
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to