Skip to content

Add embedded code-size benchmarking scripts#265

Open
AaronWebster wants to merge 1 commit into
masterfrom
me/embedded-size-bench
Open

Add embedded code-size benchmarking scripts#265
AaronWebster wants to merge 1 commit into
masterfrom
me/embedded-size-bench

Conversation

@AaronWebster

Copy link
Copy Markdown
Collaborator

What

Adds two developer scripts under scripts/ for measuring the static code size of
Emboss-generated C++ across embedded toolchains and git revisions, so the ongoing
Ok() / switch code-generation work can be quantified on real targets.

scripts/embedded_bench.sh [out-dir]

Cross-compiles a tiny freestanding TU that forces LargeConditionals::Ok() (from
testdata/many_conditionals.emb, a 100-way tag switch) into an object file, then
reports the object's size totals and the Ok() symbol size via nm --size-sort
on:

  • ARM Cortex-M4 / Thumb-2 (arm-none-eabi-g++)
  • MicroBlaze big-endian (microblaze-buildroot-linux-gnu-g++)
  • Host x86-64 (g++, reference)

-ffunction-sections/-fdata-sections keep the per-symbol and TU numbers
comparable across compiles; EMBOSS_BENCH_FLAGS overrides the compiler flags; and
any missing toolchain is skipped with a warning rather than failing the run. The
measured header is refreshed from the live generator via
scripts/regenerate_goldens.py, so only the out-dir is written.

scripts/profile_tool.py --revisions <a> <b> ... [--configs cfg.json] [--out-dir dir]

Drives embedded_bench.sh across multiple git revisions and compiler
configurations (default Os/O2/O0). It pulls the schema and harness forward
from the starting revision so the comparison measures generator output rather than
the test surface, then writes <out-dir>/profile_report.md containing, for each
target and optimization level, the TU and per-Ok()-symbol sizes for every
revision with deltas against the baseline revision. Requires a clean tree and
restores the original branch on exit (including on failure).

Notes

  • No production or build code changes; scripts/ are standalone dev tools and are
    not part of any Bazel target.
  • The fixtures (testdata/many_conditionals.emb, its golden, and
    scripts/regenerate_goldens.py) already exist on master.

scripts/embedded_bench.sh cross-compiles a small freestanding driver
that forces LargeConditionals::Ok() into an object file, then reports
the object's `size` totals and the Ok() symbol size on:
  * ARM Cortex-M4 Thumb-2 (arm-none-eabi-g++)
  * MicroBlaze big-endian (microblaze-buildroot-linux-gnu-g++)
  * Host x86-64 (reference)
-ffunction-sections/-fdata-sections keep the per-symbol and TU numbers
comparable across compiles; EMBOSS_BENCH_FLAGS overrides the flags and
missing toolchains are skipped with a warning. The measured header is
refreshed from the live generator via scripts/regenerate_goldens.py.

scripts/profile_tool.py drives embedded_bench.sh across multiple git
revisions and compiler configurations, pulling the schema and harness
forward from the starting revision so the comparison measures generator
output rather than the test surface. It writes a markdown report of TU
and per-symbol sizes with deltas against the baseline revision.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant