User Interface | SmartSync | GenericSync | Persistence | Trace | General Programming Tips

 

Performance Recommendations - Trace

Recommendation

Description
Use caution when using tracing in frequently used coding.

Tracing can be very useful to analyze the source of a problem, however it also uses resources. Limit tracing statement to absolute necessary level. So not uses trace statements in program loops.

Concatenate strings only when tracing is activated.

If the description of the trace is more than one string, concatenate the strings only when tracing is activated. String concatenation is more resource consuming than an if statement.

Example:

Wrong:

Trace trace = Trace.getInstance(“MyComponent”);
trace.log(Severities.DEBUG, “Some “ + “information”);

“Some” and “information” will always be concatenated, even if the trace is off or not logging at DEBUG level.

Right:

Trace trace = Trace.getInstance(“MyComponent”);
if (trace.isLogging(Severities.DEBUG)) trace.log(Severities.DEBUG, “Some“ + “information”);

 

 

Remark:

This recommendation is also valid for ME2.1 which uses the Log class.