2013-04-04 68 views
2

我正在一个预先存在的c#/ asp网站上工作,我试图优化它。c#网站 - 分析代码和查询

要做到这一点,我想知道每个页面上有多少SQL查询。如果可能的话,找出它放在服务器上的负载是多少,或者如果这是不可能的,则执行请求所花费的时间。

我可以使用哪些工具,我该如何操作?

我使用Visual Studio 2012 Ultimate和我连接到SQL Server 2005,如果你想知道

+0

查询,你的意思是SQL查询? – 2013-04-04 12:59:58

+0

@ManishMishra是的。谢谢你指出,我已经更新了我的问题。 – James 2013-04-04 13:00:42

+0

谢谢我通过关于Firebug的答案中途。 :-S – 2013-04-04 13:01:12

回答

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#代码,请使用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. 
1

我可能还建议New Relic,这是一个免费试用开始与商业服务,然后移动到你的应用程序性能的检查,如果你不想为它付出自由层。

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

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