This module helps you track down problematic code in your XAF solution with the use of the PerformanceDiagnosticUtil. This Module will display how many times a tracked section of code is called, how long the application spent on those calls in total, and the average of time spent by the application per code call.
Getting Started
Install the LlamachantFramework.Performance.Module from NuGet into your solution.
Include LlamachantFramework.Performance.Module.LlamachantFrameworkPerformanceModule in the RequiredModuleTypes collection of your .Module project
Enable the module to work only in debug mode by setting Instance.Enabled = Debugger.IsAttached
Run your application and click Measure BO Performance then set the type to a business object to inspect. Alter any other settings or add in filters as needed then click OK to view the results.
Click Show Performance Results to view results at any time while testing
Click Reset Performance Results to remove all calculated counters
Remember not to enable outside of debuggingThis module requires resources to capture performance metrics. It is recommended to only enable it while debugging to save on resources.
Register and Enable the Module
public YourApplication() {
InitializeComponent();
this.RequiredModuleTypes.Add(typeof(LlamachantFramework.Performance.Module.LlamachantFrameworkPerformanceModule));
LlamachantFramework.Performance.Module.Utils.PerformanceDiagnosticUtil.Instance.Enabled = Debugger.IsAttached; //This line is critical
}
Diagnose Custom Code
It is recommended to use a try finally block with the start and stop timers to track a section of the code for best results.
This section tracking will work for controllers or any other part of your application. To record performance metrics, run the actions in the application that use the tracked code then click on Show Performance Results.
try{
PerformanceDiagnosticUtil.Instance.StartTiming();
//lines of code you want to inspect go here
}
finally{
PerformanceDiagnosticUtil.Instance.StopTiming();
}
Call Tracing
The Performance Results window displays a detail view on the side that records a call trace for tracked code. Here you can find which methods call the code segment and in what order the code segment is called.