Perf stat for a part of a program

Is it possible if perf only collects hardware counter statistics for a portion of the program execution? If so, how?

likwid offers a feature to detect named regions, but it would be great if this was possible on systems with performance installed.

Some of the previous questions returned relevant answers, but there are still some drawbacks:

  • Using the probe I am getting the same error and I am using a slightly newer kernel (3.13). Are these fixes available in a newer version?
  • Using perf_event_open I would like to keep the flexibility to define events on the command line. I also looked into the performance code, but it doesn't seem to set things up by calling perf_event_open.

source to share

All Articles