← retour aux snippets

perf record/report: profilage offline reproductible

Capturer des échantillons CPU puis analyser à tête reposée avec symboles et callgraph.

bash monitoring #perf#record#report

objectif

Comparer des builds et générer des rapports stables (callgraphs, IPC).

code minimal

sudo perf record -g -- ./app --workload
sudo perf report --no-children --stdio | sed -n '1,60p'

utilisation

# limiter à un PID et user-space
sudo perf record -g -p $(pgrep -xo app) --call-graph dwarf -- sleep 10
sudo perf report

variante(s) utile(s)

# exporter en perf.data + script (flamegraph ensuite)
sudo perf script > out.perf

notes

  • --call-graph dwarf améliore les callgraphs (plus coûteux).
  • vérifiez perf_event_paranoid et les symboles de debug.