Skip to main content
Use this workflow when firmware misses a budget for size, latency, throughput, or power. Choose one primary metric and a repeatable workload before you change anything. Keep correctness and secondary limits visible, so a speed gain doesn’t hide a memory or power regression.

Choose a metric

Define the workload and conditions in the request:

Use the right observation

Each tool answers a different question. None of them proves a bottleneck on its own. For power, use the same supply, instrument mode, and settling time for every run. A Joulescope always needs an external supply. A PPK2 can supply the target in Source meter mode or measure an external supply in Ampere meter mode. For a long test, ask for streaming or a Joulescope JLS recording instead of one-shot captures. In VS Code, captures open in the Monitor’s Power tab.

Record a baseline

Save the source revision, toolchain, compiler flags, board revision, supply, workload, and measurement method. Repeat the measurement enough times to show its variation, and report more than a single favorable sample. For size:
For power, with a PPK2 as the board’s only supply:
For timing, save the trigger, channel assignments, and achieved sample rate. To watch a trend over time, use live plots, as long as the firmware’s logging overhead doesn’t distort the metric.

Find a candidate

Ask Embedder to inspect the code path that accounts for the measured cost and propose one specific change. For changes to scheduling, clocks, memory layout, or architecture, run /plan first and review the plan in Plan mode before implementation.

Repeat the unchanged measurement

After the focused change:
  1. Run the 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.
If the change doesn’t beat the measurement’s variation, treat it as no improvement. Keep the measurement protocol and results in the project. Save a repeated benchmark as a hardware script so later changes use the same procedure. See Combined workflows for relating logs, target state, and instrument captures.
Last modified on November 13, 2026