QTRC Trace Tips

Performance

When a QTRC Trace API is called, the trace conditions for the specified component are always checked. When tracing is not active for the specified component, and the QTRC Trace APIs are called multiple times, there may be a noticeable performance impact. To avoid the performance impact the QtrcGetActiveLevel() API can be used, and the results saved into a variable for later uses. Assume an application program does the following:

    const char *myComp = "MYCOMP";
    unsigned int myCompActLvl;
    QtrcGetActiveLevel(myComp, &myCompActLvl);

The application can use the myCompActLvl variable to quickly check if the component's active trace level is in effect, just prior to calling any of the QTRC Trace APIs that write trace data.

Condition to Check API Coded Trace Level
if (myCompActLvl >= QTRC_LEVEL_ERROR) QTRC_LEVEL_ERROR
if (myCompActLvl >= QTRC_LEVEL_INFO) QTRC_LEVEL_INFO
if (myCompActLvl >= QTRC_LEVEL_VERBOSE) QTRC_LEVEL_VERBOSE

It is important that the if-condition checks for greater than or equal to the trace level. This is done to keep the same semantics of how the QTRC Trace APIs check the component's active trace level against the coded trace level parameter. The variable should be periodically updated, using the QtrcGetActiveLevel() API, to ensure a current view of the component's active trace level. For example, the variable should be updated in the following conditions:

A simplified check of the variable could be used instead, for those cases where the performance impact is less critical, when any type of tracing (ERROR, INFO, or VERBOSE trace) is active:

    if (myCompActLvl != QTRC_LEVEL_NONE)

In some cases, the performance impact of tracing, whether tracing is active or not, is of no concern. This is most often the case for ERROR-level trace points, since error conditions should not normally occur within the application. Namely, the ERROR-level trace points would normally not be reached. In those cases, the QTRC Trace API that writes trace data can be called directly, without using the QtrcGetActiveLevel() API and checking the variable as described above.

Character Data Processing

The QTRC Trace APIs do not convert character data as it is being processed. Hence, it is important to understand and follow certain guidelines, when using character data on various parameters of the QTRC Trace APIs:


[ Back to top | QTRC Trace APIs | APIs by category ]