How to narrow down perf.data to a time sub interval

Viewed 806

I use linux perf (perf_events) to produce a perf.data file with timestamps.

How can I generate a report of all the events in a sub interval of time [i-start, i-end]?

Can I maybe narrow down perf.data to a perf_subinterv.data file with only events in [i-start, i-end]?

I need to do this to analyze short intervals (2s - 6s) of poor performance every 5mins or so.

2 Answers

Most perf tools, including perf report, support filtering by time:

--time::
  Only analyze samples within given time window: <start>,<stop>. Times
  have the format seconds.microseconds. If start is not given (i.e., time
  string is ',x.y') then analysis starts at the beginning of the file. If
  stop time is not given (i.e, time string is 'x.y,') then analysis goes
  to end of file.

For more details see man perf-report.

This is present since version 4.10 (Feb 2017). If you run an older kernel you can try to build the userspace tools part of perf yourself. In more recent versions it is possible to specify time percent and multiple time ranges.

Related