8

I would like to capture the hit time, processing time, memory consumption and response time of requests in ASP.NET MVC application.

Is there any way or tool to perform this?

vinodpthmn
  • 1,062
  • 14
  • 28

3 Answers3

11

Check the miniprofiler, developed by the stackoverflow team

http://code.google.com/p/mvc-mini-profiler/

This helps you to do some analysis. There is a nuget pacakge available which you can use to add this to your project.

Scott has written a post about how to use that.

You can also look into Glimpse.

There are commerical products to do memory and performance profiling like telerik just trace. You can download their trial version and use that

Shyju
  • 214,206
  • 104
  • 411
  • 497
  • Scott also has a [post](http://www.hanselman.com/blog/IfYoureNotUsingGlimpseWithASPNETForDebuggingAndProfilingYoureMissingOut.aspx) on Glimpse, ok what yout think on **min profiler vs glimpse** , which to use when profiling a online shopping site ? – Shaiju T Feb 23 '16 at 09:42
6

You can create your own little performance test monitor. This is from page 670 of Steven Sanderson's book, Pro Asp.Net MVC 2 Framework:

public class PerformanceMonitorModule : IHttpModule
{
    public void Dispose() { /* Nothing to do */ }
    public void Init(HttpApplication context)
    {
        context.PreRequestHandlerExecute += delegate(object sender, EventArgs e)
        {
            HttpContext requestContext = ((HttpApplication)sender).Context;
            Stopwatch timer = new Stopwatch();
            requestContext.Items["Timer"] = timer;
            timer.Start();
        };
        context.PostRequestHandlerExecute += delegate(object sender, EventArgs e)
        {
            HttpContext requestContext = ((HttpApplication)sender).Context;
            Stopwatch timer = (Stopwatch)requestContext.Items["Timer"];
            timer.Stop();

            if (requestContext.Response.ContentType == "text/html")
            {
                double seconds = (double)timer.ElapsedTicks / Stopwatch.Frequency;
                string result =
                string.Format("{0:F4} sec ({1:F0} req/sec)", seconds, 1 / seconds);
                requestContext.Response.Write("<hr/>Time taken: " + result);
            }
        };
    }
}

Then add to your web.config:

<add name="PerfModule" type="Namespace.PerformanceMonitorModule, AssemblyName"/>
Mike Richter
  • 329
  • 1
  • 3
2

Not free but it is really good:

http://www.jetbrains.com/profiler/

dotTrace is a family of performance and memory profilers for .NET applications.

Our latest release, dotTrace 5.2 Performance, helps .NET developers quickly find performance bottlenecks and optimize their applications.

Nesim Razon
  • 9,684
  • 3
  • 36
  • 48
  • This is good, for local usage, but if you have to check the performance on a clients site, things get much more complicated, and the miniprofiler Shyju talks about is very handy in that case. – Squazz Mar 29 '16 at 13:48