Time two builds with one scratch program, using the build's own compile and link lines
When to use#
You must A/B a code path between two versions of a CMake/Ninja project (for example a git worktree at the old commit and the working tree), no benchmark in the repo covers it, and you must not add one to either tree.
Steps#
Write the timing program in a scratch folder. Use only the public headers. A helper type from the tests (such as a test sink) is not in the library, so define a small one in the program.
In each tree, build a benchmark target that links the same library, so the libraries are current:
cmake --build <tree>/build/build-release --target <bench>.Take that target's compile and link lines from Ninja and swap in your source, object and output:
cc= ln=The last
sedterm points the rpath at the tree's ownlib/, so each binary loads its own libraries.Give each run fresh input (copy the data into a new folder per run), so a cache that one run writes does not serve the next.
Alternate A and B runs and compare medians. Run nothing else heavy meanwhile.
Evidence#
- dftracer-utils stage 10b (2026-09-27):
qc_bench.cppbuilt against a54be906 and the working tree throughindex_bench's lines. The first try failed witherror: unknown type name 'StringSink'(a type fromtests/trace/views/test_view_common.h); a localNullSink : ExportSinkfixed it. Three alternating runs gave medians within 1.3% between the builds.