Tracing and Optimization
- Last UpdatedJun 02, 2022
- 3 minute read
Suggestions to minimize the speed of start-up of addins have been made above. There are 2 built-in ways to monitor this and investigate the reasons if poor performance is suspected.
Reviewing Addin Start-up Time
Target start-up time for an Addin should be no more than 1 second, if possible. To find out how long your Addin takes to start-up set the following environment variable:
set AVEVA_CAF_TRACING=PERFORMANCE
Output similar to the following will then be displayed in the Console Window:
AVEVA Everything3D Design Mk2.1.0[10061] (WINDOWS-NT 6.3)
Copyright 2012 to current year. AVEVA Solutions Limited and its subsidiaries. All rights reserved.
Issued to UKCAMSPLS
Loading addins took: 0.282 secs.
Starting addin Explorer: 0.984 secs.
Starting addin DrawList: 0.024 secs.
Starting addin Collections: 1.264 secs.
Starting addin History: 0.011 secs.
Starting addin ReferenceList: 0.170 secs.
Starting addin PipeCheck: 0.447 secs.
Starting addin Find: 0.117 secs.
Starting addin Links Addin: 0.042 secs.
Starting addin Attributes: 0.706 secs.
Starting addin Status Controller: 0.016 secs.
Starting addin ModelChanges: 0.047 secs.
Starting addin SVGCompare: 0.612 secs.
Starting addin Aveva.Core.InstrumentationImport.Addin.DataUpdate: 0.114 secs.
Starting addin Aveva.Core.AVEVANetExportConfigAddin: 0.237 secs.
Starting addin Aveva.Core.ReportingAddin: 0.327 secs.
Starting addin MessageAddin: 0.240 secs.
Starting addin Integrator: 0.533 secs.
Total time starting addins: 5.905 secs.
Loading UIC file
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\MyDataAddin.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\StatusController.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\design.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\CoreSchematicMenu.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\SVGCompare.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\AVEVA.design.cabling.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\AVEVA.design.hvac.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\AVEVA.design.MDS.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\AVEVA.design.piping.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1.customisation\AVEVA.design.steelwork.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\MessageWindowCoreMenus.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\AVEVA.design.laser.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\Integrator.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\DiagramViewer.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1\InstrumentationImportAddin.uic
Defined new tools
Loading UIC file C:\AVEVA\Plant\E3D2.1.customisation\Model.Addin.uic
Defined new tools
Updating CommandBar Layout: 0.002 secs.
Loading CommandBar layout: 0.172 secs.
DockManager.LoadFromXML: 2.628 secs.
Loading Window Layout: 3.227 secs.
Standard Tracing
The standard facilities found in the classes of the Aveva.Core.Utilities.Tracing namespace can be used for tracing performance problems as well as for other general coding investigations.
The PdmsTrace class gives access to all the facilities of the Plant Design Management System (PDMS) trace system and provides a means of outputting general trace messages and values during processing. PdmsTrace functions also enable querying and setting of PDMS trace flags; give access to the current state of the call stack; and allow starting and stopping of Central Processor Unit (CPU) time tracing.
The TraceEntry class provides the means to trace the entry and exit of functions as processing takes place. As the nesting of function calls gets deeper and deeper the function entry messages are indented further and further. Though this output can quickly get verbose it can frequently give evidence of problems in the code - for example functions being called too frequently … or not at all!
To work correctly in C#, TraceEntry needs to know about entry and exit from functions in correct chronological order. There is a difficulty with this in C# because of the way that "garbage collection" works in that language. This means, in particular, it is necessary to make sure that the function exit event occurs at the right moment. This can be achieved by using the Dispose method explicitly:
TraceEntry tr = TraceEntry.Enter("Start", (TraceNumber)101);
// ...
// code being traced ...
// ...
tr.Dispose(); // explicit call on exit
There are still problems with this however as you will need to catch every "return" statement individually. Also the Dispose() method will never be called if an exception occurs. A simpler and more robust way is to do this job using the C# "using" command as follows:
using (TraceEntry tr = TraceEntry.Enter("Start", (TraceNumber)101))
{
// ...
// code being traced ...
// ...
} // implicit call to Dispose() on exit from the block
// even if there are exceptions or multiple return statements
If you are using these facilities to investigate the start-up of an addin, you will need to set the chosen trace flag from your code:
PdmsTrace.SetTraceFlag((TraceNumber)101, 1);
And, finally, you can use the CPU time profiling options in conjunction with TraceEntry by using:
PdmsTrace.StartCPUTrace();
// ...
// code being timed ...
// ...
PdmsTrace.StopCPUTrace(true);