Tracy Profiler
A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications. - github
Installation
On linux, need to build from source.
Notes: by default it compile for Wayland. Need X11 => need to enable LEGACY option in CMake build settings (-DLEGACY=ON) This will require glfw.
Otherwise it’s rather easy to build:
Tracing C++
Include in your code (look in example folder):
and compile with
For short program Add -DTRACY_NO_EXIT
The part above is refered as client setup in the documentation.
Then
1- Start tracy-profiler
- (the server) and click connect (start listening socket)
2- launch your executable - (the client)
If everything goes well this will give some data into the profiler.
Instrumentation
With the steps mentioned above, you will be able to connect to the profiled program, but there probably won’t be any data collection performed. Unless you’re able to perform automatic call stack sampling (see chapter 3.15.5), you will have to instrument the application manually.
Notes the API sometimes rely on unique ptr (unique adress) for string definition. Make sure to read the doc refering to that part, eg this is the case for FrameMarker:
Frame
To slice the program’s execution recording into frame-sized chunks.
Zone
To record a zone’s execution time add the ZoneScoped macro at the beginning of the scope you want to measure. This will automatically record function name, source file name and location. Optionally you may use the ZoneScopedC( 0xRRGGBB ) macro to set a custom color for the zone. Note that the color value will be constant in the recording.
Plotting Data
Tracy is able to capture and draw value changes over time.
Message Log
You can send messages (for example, your typical debug output) using the TracyMessage( text, size ) macro;
Memory Profiling
Callstack
The easiest way is to launch instrument code with high privilege => this will allows stack sampling and stack collection
You can force call stack capture in the non-S postfixed macros by adding the TRACY_CALLSTACK define, set to the desired call stack capture depth.
see also
Alternatives
- VTune - intel proprietary tools
- Optik (Brofiler) / HN - how to make it work on linux is unclear
- KUtrace / HN - an extremely low-overhead Linux kernel tracing facility for observing all the execution time on all cores of a multi-core processor, nothing missing, while running completely unmodified user programs written in any computer language.