You create a Web Part that calls a function named longCall.
You discover that longCall takes a long time to execute. You need to display in the Developer Dashboard how long it takes to execute longCall.
Which code segment should you use?
A.
DateTime startTime = DateTime.Now;
longCall();
Trace.Write(“Long Call ” + DateTime.Now.Subtract(startTime).Seconds);
B.
DateTime startTime = DateTime.Now;
longCall();
Trace.TraceWarning(“Long Call ” + DateTime.Now.Subtract(startTime).Seconds);
C.
Monitor.Enter(“Long Call”);
if (true)
{
longCall();
}
Monitor.Exit(“Long Call”);
D.
using (SPMonitoredScope monitoredScope = new SPMonitoredScope(“Long Call”))
{
longCall();
}
Explanation:
MNEMONIC RULE: “Developer Dashboard = SPMonitoredScope”Monitors performance and resource use for a specified scoped block of code.
SPMonitoredScope Class
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.spmonitoredscope.aspx