views:

1107

answers:

1

On my application, after enabling ASP.NET Tracing in an ASP.NET MVC application, the time calculation statistics were off by a factor of 5000.

I have a page that is taking between 7 and 9 seconds to load. This is corroborated by both Firebug and the "time-taken" field in the IIS log files. (This is just the page returning to the client, not any layout, DOM, or script execution.)

However, when I turn application-wide tracing on (via web.config) and view the trace output, the time taken from "Begin PreInit" to "End Render" is less than 0.001 seconds.

I assume this is because Trace.axd was built with WebForms in mind, and MVC bypasses the traditional page lifecycle.

Yet even if I add custom traces at the start and end of OnActionExecuting/OnActionExecuted, the time is still less than 0.1 seconds.

Does anyone know where in ASP.NET MVC I will need to hook in order to have the trace.axd output report accurate execution times?

+4  A: 

It could be that the time for the action method itself is not the big part of the execution. Try checking the time between OnResultExecuting/OnResultExecuted. This is basically the time to actually render the page in HTML whereas OnActionExecuting/OnActionExecuted is (basically) the time to set up the data for the view.

Note that if you are using LINQ, the data queries themselves may be deferred until the page is rendered (the model enumerated). That is, the slowness may not be due to page complexity but data access even when the time is taken in executing the result.

tvanfosson
+1 good point about lazy loading
RedFilter
Yup, OnResultExecuted shows a 9 second delay. Now to figure out why... (I always .ToList() my Linq before assigning it to the model, so it's not deferred execution. I think I my crappy nested Master pages might be the culprit.)
Portman