MVC mini profiler, a simple effective profiler for mvc

Use Nuget to download mini profilder,

install-package miniprofiler

To use it, start the profiler in Global.asax, Application_BeginRequest()

protected void Application_BeginRequest()

{

    if (Request.IsLocal)

    {

        MiniProfiler.Start();

    }

}

Write a condition to start the profiler, for Local Request, for special users, etc.

To use profiler for your code,

var profiler = MiniProfiler.Current; // it's ok if this is null

using (profiler.Step("Set page title"))
{
    for(int i=0;i<100;i++){

//do something

}

}

To display on the page, you need to include the profiler to _Layout.cshtml,

    @MvcMiniProfiler.MiniProfiler.RenderIncludes()

To end a profiler, end it in Global.asax, Application_EndRequest(),

protected void Application_EndRequest()

{

    MiniProfiler.Stop();

}

Advertisements