Hi, I’m trying to reproduce the profiling info available in SS Profiler but using StackExchange Miniprofiler.
Therefore I want to have the following steps profiled:
- Deserialize Request
- Executing Request Filters
- Execute Service
- Executing Response Filters
- Writing to Response
I created my Service Runner to handle the Execute Service: and the Executing Request Filters steps:
public class ProfiledServiceRunner<T> : ServiceRunner<T>
{
public ProfiledServiceRunner(IAppHost appHost, ActionContext actionContext)
: base(appHost, actionContext)
{
}
public override void OnBeforeExecute(IRequest requestContext, T request)
{
requestContext.Items["MiniProfilerExecute"] = MiniProfiler.Current.Step("Executing Service");
base.OnBeforeExecute(requestContext, request);
}
public override object OnAfterExecute(IRequest requestContext, object response)
{
var disposable = requestContext.Items["MiniProfilerExecute"] as IDisposable;
if (disposable != null)
disposable.Dispose();
return base.OnAfterExecute(requestContext, response);
}
public override void BeforeEachRequest(IRequest requestContext, T request)
{
requestContext.Items["MiniProfilerRequest"] = MiniProfiler.Current.Step("Executing Request");
base.BeforeEachRequest(requestContext, request);
}
public override object AfterEachRequest(IRequest requestContext, T request, object response)
{
var disposable = requestContext.Items["MiniProfilerRequest"] as IDisposable;
if (disposable != null)
disposable.Dispose();
return base.AfterEachRequest(requestContext, request, response);
}
}
The Executing Service step works fine. But I get a weird result for my Executing Request step, which has a negative duration:
http://content.screencast.com/users/carlos.mendes/folders/Jing/media/e4b2439e-e2e4-4bc2-899e-459cb7249343/2015-04-16_2123.png! (please remove the ! from the URL to see the result. apparently new users cannot post images)
What I’m I missing here?
Also, how can I profile the missing steps?
- Deserialize Request
- Executing Request Filters
- Executing Response Filters
- Writing to Response
Thanks in advance