How to analyze query performance in an ASP.NET MVC application?

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

Is there a way or tool for this?

+8
performance c # asp.net-mvc iis-7
source share
3 answers

Check out miniprofiler developed by stackoverflow team

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

This will help you do some analysis. There is an available nuget pacakge package that you can use to add it to your project.

Scott wrote a post on how to use it.

You can also watch Glimpse .

There are commercial products for creating memory and profiling performance such as telerik that are easy to track . You can download your trial version and use it.

+11
source share

You can create your own performance monitor. This is from page 670 of Stephen 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"/> 
+6
source share

Not free, but it's really good:

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

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

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

+2
source share

All Articles