2

我正在开发一个预先存在的 c#/asp 网站,并且正在尝试对其进行优化。

为此,我想了解在每个页面上进行了多少 SQL 查询。如果可能的话,找出它给服务器带来了多少负载,或者如果不可能,找出执行请求所花费的时间。

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

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

4

2 回答 2

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.

在此处此处阅读有关此内容的更多信息

现在,如果您想基于其 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# 代码,请使用 Microsoft.NET 这个免费的可用工具,称为FxCop

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.
于 2013-04-04T13:03:47.273 回答
1

我也可能会建议New Relic,它是一项商业服务,一开始是免费试用的,然后如果您不想付费,则将您转移到应用程序性能检查的免费层。

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

注意:您需要完全访问服务器才能安装监控服务。

于 2013-04-04T13:16:23.997 回答