Description:
Today, I encountered a strange problem at the customer's site. The access to the SharePoint 2010 homepage was very slow (other sites were normal), but it was still good last night. I want to report it to the leaders again today, I am so anxious. I am sad ..
It seems that there was a problem with the webpart, but it was always good in the past. The initial troubleshooting should be caused by a problem with the access data of the webpart on the homepage,
The homepage is nothing more than content query, and content editing EXCEL-related webpart. To find out which webpart is the cause of my homepage being incredibly slow ~~~
I was puzzled. I suddenly remembered that SharePoint2010 had a Developer dashboard to analyze the website's execution. (After the service is enabled, it becomes very clear ....)
Two methods:
Code:
SPPerformanceMonitor perfmon = SPFarm. Local. extends cemonitor;
Perfmon. Fig level = SPPerformanceMonitoringLevel. On;
Perfmon. Update ();
Cmd:
STSADM-o setproperty-pn developer-dashboard-pv on (or "on" or "off ")
Use SPMonitoredScope to monitor your code details
With SPMonitoredScope, you can easily output the performance information of a code segment to the Developer Dashboard. It is easy to use SPMonitoredScope. First, declare an instance of SPMonitoredScope and assign a tracing name to write the code that requires a Track. For example, the following code shows how to insert a list item:
Using (SPMonitoredScope monitoredScope = new SPMonitoredScope ("My Monitored Scope "))
{
// Put code to monitor performance on here
SPList testList = site. Lists. TryGetList ("Test List ");
If (testList! = Null)
{
SPListItem listItem = testList. Items. Add ();
ListItem ["Title"] = string. Format ("Test Item {0}", Guid. NewGuid (). ToString ());
ListItem ["City"] = "Somewhere ";
ListItem ["Quantity"] = 3;
ListItem. Update ();
}
}
In SPMonitoredScope, you can also use nested SPMonitoredScope objects to analyze performance with smaller code segments as detailed as possible.
Using (SPMonitoredScope monitoredScope = new SPMonitoredScope ("My Monitored Scope "))
{
SPList testList;
Using (SPMonitoredScope getListMonitor = new SPMonitoredScope ("Get List "))
{
TestList = site. Lists. TryGetList ("Test List ");
}
Using (SPMonitoredScope addListItemMonitor = new SPMonitoredScope ("Add List Item "))
{
If (testList! = Null)
{
SPListItem listItem = testList. Items. Add ();
ListItem ["Title"] = string. Format ("Test Item {0}", Guid. NewGuid (). ToString ());
ListItem ["City"] = "Somewhere ";
ListItem ["Quantity"] = 3;
ListItem. Update ();
}
}
}
As expected, we can see more detailed monitoring segments Get List and Add List Item in My Monitored Scope. In this way, we can clearly see the performance of each code segment.