Commit Graph

1 Commits

Author SHA1 Message Date
Ian Rogers
164c7edd80 perf python: Port task-analyzer to perf module
Port task-analyzer.py from tools/perf/scripts/python/ to a standalone
script in tools/perf/python/ refactored into a class-based architecture.

Improvements compared to the legacy script:
- Support both offline perf.data file analysis (using perf.session) and
  live trace capture (using evlist.read_on_cpu), accessing
  sched:sched_switch tracepoint fields directly from sample objects.
- Automatically disable ANSI terminal color escape sequences when --csv
  or --csv-summary is enabled so CSV column headers ('Comm,',
  'Time Out-Out,', etc.) are never polluted by color codes when running
  interactively on a TTY (e.g. as root).
- Sanitize non-printable characters and leading CSV formula characters
  (=, +, -, @) in task comm strings.
- Emit a one-time warning to stderr if sched:sched_switch samples are
  missing tracepoint fields (such as when recorded without libtraceevent
  support).

Update test_task_analyzer.sh to invoke the standalone script.

Assisted-by: Antigravity:gemini-3.1-pro
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-09-26 20:49:30 +02:00