문제

I'm currently investigating performance issues on our web app (MVC2, S#arp Architecture, fluent nHibernate), using the MVC-mini-profiler which is great. I am using an attribute on actions or controllers I want to investicate as discussed in this post Getting more "granularity" from the MVC Mini Profiler.

I'm finding that a lot of time is spent between the OnResultExecuting and onResultExecuted, I figured this must be rendering the view so if there was complex logic called from there that would be the problem, but I've put a number of profiler calls around parts of the views, including one around the whole of the master page, but there is still a lot of time (about 4-5 seconds in some cased) that is completely unaccounted for.

I don't really understand what is happening in the step after OnResultExecuting other than rendering the view, so don't even know where to look for the performance problem.

Any pointers would be appreciated.

도움이 되었습니까?

해결책

Are you creating view models to pass to your views for rendering? If a view model has a collection of something, and that collection is populated using a Linq query on NHibernate then it's possible that the Linq query is being executed as part of rendering the view. This means that some of the 4-5 seconds could be taken up with database access. As a rule, any code that creates a view model should ensure that all collections in that view model are fully populated rather than being IQueryables that have not yet been enumerated.

Does this sound like a possibility? If so, using NHProf might help pin it down.

다른 팁

My best guess is that it commits UnitOfWork (ISession in NHibernate). This could be quite time consuming operation.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top