Optimizing nhibernate session factory, startup time of webApp really slow

后端 未结 2 1850
情书的邮戳
情书的邮戳 2021-02-02 13:33

I have implement testing app. which uses fluent nhibernate mapping to db object inside mssql db. Since I want to learn fine tune nhib. mvc3 applications, I\'m using this app. fo

2条回答
  •  别跟我提以往
    2021-02-02 14:28

    IIRC correctly, it is not a good idea to create objects in the contructor of HttpApplication (or its subclasses such as MvcApplication). Better to create the session factory in the Application_Start handler.

    You should remove NHibernate profiler (since all profilers might affect the measurements). Instead, put the call to CreateSessionFactory() and surround it with use of the Stopwatch class to get an accurate measurement.

    Is your database server slow to respond? Because of connection pooling this might only be noticeable on the first occasion.

    NHibernate do take some time to initialize, but 4 seconds with one lightweight entity do seem too much. This is of course affected by the general performance of the test system though.

提交回复
热议问题