Tracy Profiler is a fantastic tool for profiling C++ applications and is something I have recently started integrating into my workflow. This guide serves as a quick guide on how to integrate it with an existing application and get your first profile. Note that these instructions assume that you are using Ubuntu 22.04 and that your project uses CMake.
Tracy Profiler has two parts, a set of macros that are included into your project and a server that receives the profiling data and displays it.
From the root of your project, clone the Tracy Profiler repository into a subdirectory of your project (master branch should be fine).
git clone https://github.com/wolfpld/tracy
Then update your project’s CMakeLists.txt as such:
option( TRACY_ENABLE "" ON)
Compile your project in debug mode.
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=DEBUG ..
Building the profile viewer
Install dependencies This will compile the viewer from source, which guarantees that the viewer is compatible with the version of profiler you are using. This will build for an X11 based system (legacy mode, not for Wayland), see the PDF documentation for Wayland-based build.
sudo apt install libglfw3-dev libfreetype-dev libcapstone-dev libdbus-1-dev
Build for X11 (won’t work on Wayland)
Build for Wayland (won’t work on X11)
This should create a binary called
Tracy-release in the
Execute this binary to start the viewer.
You should now have a profile viewer running on your machine like:
Profiling your application
Now that you have the viewer built (and running) it’s time to profile your application. Running your application under sudo is required to allow the profiler to access the system’s performance counters.
You should now be able to see a profile like: