Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ninject and performance

I am doing a code review on a web site that will have a lot of simultaneous users, ca. 100,000 authenticated users.

I have found the following code of type:

    [Inject]
    public BusinessLayer.ILoginManager LoginManager { get; set; }

And in global.asax.cs:

   protected Ninject.IKernel CreateKernel()
    {
        return new StandardKernel(new ServiceModule());
    }


    internal class ServiceModule : NinjectModule
    {

        public override void Load()
        {
             Kernel.Bind<IReportProxy>().To<ReportProxy>().InRequestScope();
        }
    }

Question is: Will the use of Ninject affect performance? Are there situations in which you should not use Ninject due to performance?

like image 812
Shiraz Bhaiji Avatar asked Feb 03 '23 19:02

Shiraz Bhaiji


1 Answers

As it always is with performance questions and issues, you cannot detect any of those just by looking at your code. Rather, profile your application and see where the problem is.

From my past experience, IoC containers only incur performance overhead on application startup and their impact is next to negligible while the app is running.

like image 150
Anton Gogolev Avatar answered Feb 06 '23 14:02

Anton Gogolev