Execution Tracking and Time Measurement
You can track the execution of a procedure and make some time measurement using the
DebugTimer
primitive and complete instructions.
Important:
To use the DebugTimer primitive, add var
DebugTimer = Java.type
(“com.dassault_systemes.completionServices.base.DebugTimer”); in the Header Section of your procedure. |
Definition of the Instructions
You must also add the following statements to the Body Section of your procedure:
- Before the method to be measured:
var MyTimer = new DebugTimer (context, traceLevel, text, traceFormat);
- After the statement to be measured:
MyTimer.complete ();
Where:
MyTimer
is a user-defined name for this time measurement step.context
is the Completion Context of the procedure.traceLevel
is a value that defines the level of the traces. The possible values are0
and1
:- If the value is
0
, then the corresponding trace will be output as soon as theCompletionServicesTraces
trace is define to0
. - If the value is
1
, then the corresponding trace will be output as soon as theCompletionServicesTraces
trace is define to1
.Recommendation: DefinetraceLevel
to0
.
- If the value is
traceFormat
is a text that defines the format of the output trace. The possible values aretrue
andfalse
:- If
true
, then the trace will be written on two lines: the first line starting with "Begin
" followed by the text defined in statement and time, and the second line starting with "End
". - If
false
, then the trace will be written on one line as follows: the line starting with "Did
" followed by the text, then "in
", and finally the required time.Recommendation: DefinetraceFormat
totrue
.Example:
Did primitive in n ms (started at p ms)
Where:
primitive
is the text.n
is the time to execute the primitive.p
is the start time (in milliseconds).
- If
Activation and Localization of Traces
If no variable is defined, no traces are generated.
To track the execution, you must declare the CompletionServicesTraces
variable in the mxEnvCAS.sh file located in
/home/data/RTV/serverName/server/scripts.
Where:
serverName
is the name of the server.
The declaration of the CompletionServicesTraces
variable must be as
follows:
CompletionServicesTraces=0 export CompletionServicesTraces
Where:
- If
CompletionServicesTraces=0
, it triggers the traces of the procedure, defined by the administrator through theDebugTimer
instructions. - If
CompletionServicesTraces=1
, it triggers the traces of the procedure and internal traces to the primitives used.
Once you have modified the mxEnvCAS.sh file, you must restart the Tomcat.
You can find the results file with the retrieved traces in the catalina.out file.
Exploitation of the Traces
Depending on the value of the traceFormat parameter, the output is different.
- If
true
, then the trace will be written on two lines: the first line starting with "Begin
" followed by the text defined in statement and time, and the second line starting with "End
".Between these two lines, you can have other
DebugTimer
instructions nested in the previous ones and indented with minus-
signs for better readability.The "
-Begin
" and the "-End
" of a nested instruction are read in pairs at the same level to indicate the beginning and the end of a primitive or step in the primitive. - If
false
, then the trace will be written on one line as follows: the line starting with "Did
" followed by the text, then the required time.Example:
Did primitive in n ms (started at p ms)
Where:
primitive
is the text.n
is the time to execute the primitive.p
is the start time (in milliseconds).