Optimize C++ with PGO and Google Benchmark
Who is this for?
Developers looking to optimize C++ performance based on runtime behavior with profile-guided optimization (PGO).
What will you learn?
After completing this Learning Path, you'll be able to perform the following tasks:
- Microbenchmark a function using Google Benchmark.
- Apply profile-guided optimization to build performance-tuned binaries.
Prerequisites
Before starting, you'll need the following prerequisites:
- Basic C++ understanding
- Access to an Arm-based Linux machine, such as an AWS Graviton-based instance or an Arm AGI CPU platform
Summary
This summary was drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
-fprofile-generate, run it to create .gcda files, and recompile with -fprofile-use. You’ll compare benchmark timings before and after PGO, inspect the generated artifacts, and integrate PGO into either a Makefile or a continuous integration Github Actions workflow.Frequently asked questions
These FAQs were drafted with an approved AI-assisted workflow and reviewed by Arm contributors before publication. Human technical review remains part of the process so the final page reflects engineering rigor, accuracy, and Arm editorial standards.
-fprofile-generate, run it to collect runtime data, then rebuild with -fprofile-use. This two-step cycle enables the compiler to use the collected profile during optimization..gcda extension in the same directory. Use these files as inputs for the subsequent -fprofile-use build..gcda files exist in the build directory. Then confirm that the recompile used -fprofile-use in the same location where the the run generated the profile files.