Using Tracy Profiler
Tracy Profiler lets you mark sections of C++ code and inspect their timing in a separate viewer.
These notes cover a CMake integration and the older Makefile-based viewer build on Ubuntu 22.04. The clone command pins Tracy to v0.10 so the paths below match. For newer releases, follow the build instructions in the Tracy repository.
Tracy consists of two components: client-side macros that you embed in your code, and a viewer application that receives and displays the profiling data in real-time.
Project Integration
First, clone the Tracy repository into your project directory:
git clone --branch v0.10 --depth 1 https://github.com/wolfpld/tracy
Next, update your project’s CMakeLists.txt to include Tracy:
option(TRACY_ENABLE "Enable profiling" ON)
add_subdirectory(tracy)
# After your existing add_executable(...) call:
target_link_libraries(your_project PRIVATE Tracy::TracyClient)
Replace your_project with your target’s name. Linking Tracy::TracyClient supplies the client implementation and include path; don’t also add TracyClient.cpp to your executable.
Include tracy/Tracy.hpp in a source file and add ZoneScoped; inside a function or scope you want to measure. Build with optimisation and debug information so the timings reflect an optimised program while retaining useful symbols:
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build
Building the Tracy Viewer
The Tracy viewer compiles from source to ensure compatibility with your client version. First, install the required dependencies:
sudo apt install libglfw3-dev libfreetype-dev libcapstone-dev libdbus-1-dev
Then build the viewer. For X11 systems:
cd tracy/profiler/build/unix
make LEGACY=1
For Wayland systems:
cd tracy/profiler/build/unix
make
This creates a binary called Tracy-release in the build directory. Launch it with:
./Tracy-release
The Tracy viewer interface will appear:

Running Your Application
With the viewer running, start your application normally to capture the instrumented zones:
cd build
./your_project_executable
Once your application starts, Tracy will display real-time profiling data:
