MVC – Mini Profiler

I’ve been really happy with the nuget platform for adding packages to VisualStudio.  If you have not yet tried nuget head on over to nuget.org.  One of the more recent packages I’ve been using is the mini-profiler.

It is a little plug-in (can’t think of another term) that allows you profile a page and elements that are executed.

Here is the blog post that I originally learned of this tool http://www.hanselman.com/NuGetPackageOfTheWeek9ASPNETMiniProfilerFromStackExchangeRocksYourWorld.aspxYou can install the mini-profiler by running the following command in your nuget command prompt

 

PM>  nuget install-package miniprofiler

Once installed you add 2 elements into your global.asmx.  Once you add those commands you can invoke the profiler around any area of code you would like to profile.

using (profiler.Step("YOUR DESCRIPTION HERE"))
        {
          //What you want to profile here. 
         // ViewBag.Message = "Welcome to ASP.NET MVC!";
        }

To display on the page you just a jquery command.

<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
    @MvcMiniProfiler.MiniProfiler.RenderIncludes()
</head>
You can get more information here: http://code.google.com/p/mvc-mini-profiler/

 

 

 

 

 

Leave a Comment