Master the fundamental concepts of profiling & measurement through this focused micro-challenge.
Dead-code elimination, constant folding, comparing debug vs release builds, and measuring only one iteration are the classic ways microbenchmarks lie. LLVM and GCC will delete loops whose results are unused. Turbo Boost makes the first timed run faster than the tenth unless you pin frequency or run long enough.
Always consume results. Match compiler flags across A/B tests. Warm up branch predictors and caches. Run on idle hardware or pin cores.
cLoading…
-O0 against -O3 and call it an optimizationuptime and load averageobjdump -d when numbers look impossibleKeep the relevant documentation open while you implement. When your output disagrees with the reference, trace one failing case by hand before changing random lines.
You will identify at least three benchmarking mistakes in provided snippets and fix them. This exercise asks you to demonstrate one pitfall (such as DCE) and show corrected timing.
Demonstrate common benchmarking pitfalls and their fixes.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github