Skip to main content
Choose one primary metric and a repeatable workload before optimizing. Keep correctness and secondary limits visible so a speed gain does not hide a memory or power regression.

Choose a metric

  • Flash and RAM: build output and linker map.
  • Latency: target timer or GPIO markers captured by a logic analyzer or scope.
  • Throughput: operation count over a defined interval.
  • Current and energy: PPK2 or Joulescope with a defined workload.
  • Executed paths: instruction trace and source coverage.

Record a baseline

Save the source revision, toolchain, flags, board revision, supply, workload, and measurement method. Repeat enough times to expose variation and report more than a single favorable sample. For size:
For timing, save the trigger, channel assignments, and achieved sample rate. Use live plots for trends when firmware logging overhead is acceptable.

Find a candidate

Ask Embedder to inspect the path that accounts for the measured cost and propose a specific change. Use Plan mode for changes to scheduling, clocks, memory layout, or architecture.

Use the right observation

GDB helps explain state but halts and stepping disturb timing. ETM shows instruction order; source coverage shows what executed. Neither establishes a bottleneck by itself. Bounded J-Trace captures reset and run the target. Streamed ETM repeatedly halts it and cannot demonstrate real-time deadlines. For power, use the same external supply or source-meter setup and the same settling time. A Joulescope needs an external supply. Use streaming or JLS recording for a long test.

Repeat the unchanged measurement

After the focused change:
  1. Run relevant correctness tests.
  2. Build with the same toolchain and options.
  3. Restore the same target state and workload.
  4. Repeat the original measurement.
  5. Compare baseline, candidate, absolute change, and run-to-run variation.
  6. Check secondary limits such as image size, current, or deadline margin.
Keep the measurement protocol and results in the project. See Combined workflows for relating logs, state, and instrument captures.
Last modified on September 12, 2026