2012-10-19 45 views

回答

11

检查miniprofiler,由计算器队

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

这可以帮助你做一些分析开发。有一个nuget pacakge可用,您可以使用它将其添加到您的项目中。

Scott写了一个关于如何使用它的post。您可以查看Glimpse

有一些商业产品可以进行内存和性能分析,如telerik just trace。你可以下载他们的试用版,并使用

+0

斯科特也有一个[文章](HTTP:/ /www.hanselman.com/blog/IfYoureNotUsingGlimpseWithASPNETForDebuggingAndProfilingYoureMissingOut.aspx)在Glimpse上,确定你对** min profiler vs瞥见**的想法,在分析在线购物网站时使用哪些内容? – stom

2

不是免费的,但它是非常好的:

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

dotTrace是性能和内存分析器用于.NET应用的家庭。

我们最新发布的dotTrace 5.2 Performance可帮助.NET开发人员快速找到性能瓶颈并优化其应用程序。

+0

对于本地使用而言,这很好,但是如果您必须检查客户站点上的性能,事情会变得更加复杂,并且小型资源配置文件Shyju谈到的在这种情况下非常方便。 – Squazz

6

您可以创建自己的小型性能测试监视器。这是史蒂芬·桑德森的书页670,临Asp.Net MVC 2框架:

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); 
      } 
     }; 
    } 
} 

然后添加到您的web.config:

<add name="PerfModule" type="Namespace.PerformanceMonitorModule, AssemblyName"/> 
相关问题