Friday, June 1, 2012

Developer Dash board in SharePoint 2010 – Part 1


Developer dashboard is a new feature introduced in SharePoint 2010. 

Developer dashboard as a name suggests helps developer to find about their code’s execution time and performance tuning. It shows how much time each database query takes and how much time web part takes to load. 

Where is the code which takes longer time to execute and delaying the page load?

Developer can easily introduce extra SPSite or SPWeb in code which can be captured from here.

It is almost like tracing in ASP.net where we trace request.

Developer dash board id by default turned off. You cannot find where that is. We need to turn it on.

There are three ways you can turn on developer dash board, through obsolete stsadm command, through new powershell command or through object model.

We are going to see each of them.

Before turning developer dash board on, we need to know few things. There are three switches for developer dash board. You can turn it on then it will always be available.

You can turn it off hence it won’t be available and you can set it to OnDemand which is the most proper setting that suits the developer. 

When we want to see we can click on icon and when we do not want to see we can once again click on icon to turn it off.

1)    Through STSADM

STSADM –o setproperty –pn developer-dashboard –pv OnDemand

Just change On or Off mode at the end based on requirement

2)    Through PowerShell

$DDboard = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
$ DDboard.DisplayLevel = 'OnDemand';
$ DDboard.RequiredPermissions = 'EmptyMask';
$ DDboard.TraceEnabled = $true;
$ DDboard.Update();

    Just change On or Off mode at the end based on requirement for DisplayLevel property.
Now here is an interesting stuff. If you see required permission property, we have set as EmptyMask that means all users will be able to access developer dash board.

We can set any SPBasePermissions mask here that will restrict only those users to view this dashboard setting.

3)    Through object model

using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
    
SPWebService DDboard = SPWebService.ContentService;
DDboard.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.On;
DDboard.DeveloperDashboardSettings.Update();
 
Now here is the interesting catch. I have created windows application to turn this developer dashboard to OnDemand mode. But if I write above code I was getting exception.
 

 
Well the problem is in Visual Studio 2010. Now you must be wondering what that problem can be. Well, answer is go to the properties of the project and change platform target to x64.
 

 
And there you go. You should be good to go then. Handy tip. Itsn’t it?
 
Change the enumeration to OnDemand or Off based on your requirement.

Keep reading Part -2 of this series.

No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com