Add --define=profiling=1
to build arguments
bazel build --define=profiling=1 -c opt //...
Perform the operations to trace, and the trace file is generated
Trace file:
livehd.trace
in current working directory
- Open Perfetto Trace Viewer - ui.perfetto.dev
- Drag trace file into the viewer
Include perf_tracing.hpp
#include "perf_tracing.hpp"
RAII
{
TRACE_EVENT(category, event);
...
}
Events that don't follow function scoping
TRACE_EVENT_BEGIN(category, event);
...
TRACE_EVENT_END(category);
Events with a runtime name
(category, nullptr, [&name](perfetto::EventContext ctx) {
ctx.event()->set_name(name);
}
);
In core/perf_tracing.hpp
, add to PERFETTO_DEFINE_CATEGORIES
perfetto::Category(category).SetDescription(description)
- Follow Record traces on Linux - Building from source
- Add
data_sources {config {name: "track_event"}}
totest/configs/scheduling.cfg
- Run
tools/tmux -c test/configs/scheduling.cfg -C out/linux -n
Inside the tmux window, there will be a command to launch the tracing session
Perform the operations to trace while session is on, and the trace file is generated
Trace file:
trace
in temporary directory