Developer Dashboard !!!

Source: Internet
Author: User

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.

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.