Tracing Cheat Sheet: Measuring Precise Intervals
This page is a quick recap of how to measure the precise timing between events happening on the target (e.g. interrupts or thread switches) using VisualGDB’s software tracing.
Tracing works by dynamically inserting recording code into the debugged program. It works very fast and introduces minimal overhead (~100 CPU cycles per event), so it can be used to accurately measure how long some code paths take. This tutorial describes it in detail, while this page provides a quick recap on how to measure the time spent between 2 lines of code:
- Set tracepoints both lines.
- Configure them to capture the Cortex-M Cycle Counter:
- Optionally,rename the tracepoints in the Tracepoints window to get more meaningful names:
- Start debugging. VisualGDB will begin collecting the trace data and the Tracepoints window will show it. Switch the view to either Events or Both:
- Now the Tracepoints window is showing the list of tracepoints (A), the list of events from each one (B) and the data captured in each one (C). However, the Trace Data view can only show data from one event at a time. To compare the timestamps from multiple events, you need to create a table view:
Note that once you create a table view, you can always re-open it during subsequent tracing sessions by selecting it from the list. - To build a table view showing the time, you would need to drag the Cycle Counter variable from the Trace Data view into the column setup area.
- As we have created 2 different tracepoints, you need to either drag the cycle counter for both of them, or drag the first one and use the “Add to index” button to automatically add the rest:
- After the values have been added, you can switch the view from Value to Time:
- Once you have selected the Time view and entered the clock frequency, you can see the exact time it took between 2 adjacent events in the table view:
If you want to learn more about the VisualGDB’s tracing features, see this page for a detailed description.