2

I'm using Glimpse to get an insight into my ASP MVC website's behaviour. I can see that view rendering seems to take the longest. My controller action takes about 122ms and does 70ms of database queries, but the code is a little complex so I can understand some time taken to complete the full action. Other, simpler controllers have action time slightly higher than time taken to perform DB calls.

However, view rendering seems to take quite a long time. For example, Glimpse reports 40ms to render the action. However, looking at the website through another browser with Glimpse disabled, I see about ~100ms rendering times using the network inspector developer panels. Is there a good way to profile view rendering so I can look for improvement? This seems to be an issue across the whole site.

Also, I'm not sure if the time shown for view rendering increases because of Glimpse itself. When checking page load speeds with it on and off it seems to add 200-300ms onto load time.

Timeline of slow views: GLimpse view rendering

Execution tab: Glimpse execution tab

The simpler controller - notice low action times but high view. simpler controller execution

Steven Sproat
  • 4,398
  • 4
  • 27
  • 40
  • Are you running the site in Debug or Release mode? Debug mode is way slower in Razor rendering as it doesn't cache views. For instance an EditorFor used in a table is very slow comparing the same in release. – Romias Feb 21 '15 at 13:31
  • Definitely Release mode, with debug off in web config. There's no action links or model-binding form elements on these pages - all URLs are generated from the controller into a custom format. Looking in Glimpse's View tab it seems that my layout file is being searched for inside of that view's folder and a few other places, even though its layout location is specified as ~/Views/Layout/Layout.cshtml – Steven Sproat Feb 21 '15 at 13:50
  • Just wondering, but is it possible that while rendering the view, you have some lazy loading going on which results in more database calls during rendering? I can't see it in the timeline, as the part Result Executed event isn't visible. – cgijbels Feb 22 '15 at 17:21
  • Also Glimpse has no direct effect on the rendering itself, but does have impact on the load time of your page, as it returns extra data to the client for processing. – cgijbels Feb 22 '15 at 17:22
  • Nah we never return entity objects to the Views - there's always a separate ViewModel class that we transfer properties onto from the entity object. Plus it seems to affect every page. I'm going to play around tomorrow in work, see if I can replicate the problem with a stripped-back version of our views. Rendering PartialViews through ajax reports very small view rendering timings so it seems to happen only for whole pages. – Steven Sproat Feb 22 '15 at 19:28
  • I can reproduce this performance problem in views that displays data in tables. Let's say I'm displaying 200 records with 5 fields (Html.DisplayFor) and 1 link (Html.ActionLink) per row - it executes in 100ms, when I output data directly it reduces time to 4ms. So the problem could be in lambda expression execution performance. – Aurimas Neverauskas May 03 '15 at 17:21
  • 1
    It turns out there's a bug in Glimpse, disabling ModelBinding tab solves the problem. – Aurimas Neverauskas May 04 '15 at 17:21

0 Answers0