c#website - 分析代码和查询

时间:2013-04-04 12:58:12

标签: c# asp.net sql-server visual-studio-2010 profiling

我正在使用预先存在的c#/ asp网站,我正在尝试对其进行优化。

为此,我想了解每页上有多少SQL查询。如果可能的话,找出它在服务器上加载了多少负载,或者如果不可能,那就是执行请求所花费的时间。

我可以使用哪些工具,我该怎么做?

我使用的是Visual Studio 2012 Ultimate,我正在连接到SQL Server 2005。

2 个答案:

答案 0 :(得分:3)

如果您想知道,在给定页面上有多少sql查询转到您的数据库服务器,分析它的最佳方法是使用SQL Profiler

SQL Profiler is a graphical tool that allows system administrators to monitor 
events in an instance of Microsoft® SQL Server™. You can capture and save data 
about each event to a file or SQL Server table to analyze later. For example,
you can monitor a production environment to see which stored procedures are 
hampering performance by executing too slowly.

详细了解此herehere

现在,如果您想根据其XHTML标记分析页面的性能,那么有很多工具可供使用。我使用的,被认为非常有用的是Firefox插件YSlow

YSlow analyzes web pages and suggests ways to improve their performance based 
on a set of rules for high performance web pages.

现在,如果您想在语义,性能,代码构造方面优化C#代码,请使用名为FxCop的Microsoft.NET免费提供的工具。

FxCop is an application that analyzes managed code assemblies (code that 
targets the .NET Framework common language runtime) and reports information 
about the assemblies, such as possible design, localization, performance, 
and security improvements. Many of the issues concern violations of the 
programming and design rules set forth in the Design Guidelines, which are 
the Microsoft guidelines for writing robust and easily maintainable code by 
using the .NET Framework.

答案 1 :(得分:1)

我可能还会建议New Relic,它是一个免费试用的商业服务,如果您不想付费,则会将您带到免费的应用程序性能检查层。

我用它来检查我的应用程序中的瓶颈,它确实有助于发现问题。它会告诉您代码中的最长时间花在哪里。

n.b您需要完全访问服务器才能安装监控服务。