2013-04-04 51 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您需要完全訪問服務器才能安裝監控服務。