Developer Dashboard Overview

Hello everyone,

Today I’ll talk about the developer dashboard. This is a new feature of SharePoint 2010 which allow you to check the events of your page as SQL queries performed, the total execution time of the page, the instantiations of SPSite / SPWeb, etc.

By default this feature is disabled. To enable it you can use the following Powershell script.


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

Let us look at this script.

DisplayLevel


$DeveloperDashboardSettings.DisplayLevel = 'OnDemand';

The display level can have three values : “On”,”Off”,”OnDemand”

The default is “Off”, if we set it to “On”, the dashboard will always be called and displayed at the bottom of the page. If we choose “OnDemand”, a button appears next to the welcome control (the one displaying the name of the user)

By clicking on this button, we display / hide the dashboard

RequiredPermissions


$DeveloperDashboardSettings.RequiredPermissions = 'EmptyMask';

“Required permissions” attribute is used to set the minimum rights necessary to see the dashboard. Here the value ‘EmptyMask’ allows anyone to see the dashboard.

For more information on the different masks, here is the msdn documentation : http://msdn.microsoft.com/library/microsoft.sharepoint.spbasepermissions.aspx

TraceEnabled


$DeveloperDashboardSettings.TraceEnabled = $true;

By adding this trace, we add a link in the dashboard providing us with a whole new set of information such as: The entire track, the control tree, the contents of cookies, session state and so on!


For more information on the dashboard, here is the msdn documentation: http://msdn.microsoft.com/library/ff512745.aspx

Moreover, we can add to our code a snippet to see how long it takes to run!

Let’s add the following code around the function we want to evaluate


using (new SPMonitoredScope("My tuto test"))
 {
FunctionToCheck() ;
}

This code snippet adds an entry to the dashboard.

More information about the SPMonitoredScope class on msdn: http://msdn.microsoft.com/en-us/library/ff512758.aspx

Happy debugging!

Christopher.

Advertisements