C Programming • C17 baseline, standards-specific features labeled
Performance Measurement and Optimization
Measure representative workloads before changing code for speed.
Optimization can alter timing and expose latent undefined behavior. Build a correct baseline, profile a representative workload, identify a measured bottleneck, and compare the result with repeatable tests. Keep optimization flags and target architecture visible in the build configuration.
Example
cc -std=c17 -O2 -Wall -Wextra -Wpedantic app.c -o app
time ./app representative-input.dat
What to expect
The optimized build can be compared with the same workload and test results from the unoptimized build.
Key idea: Do not trade correctness or portability for a performance improvement you have not measured.