https://github.com/rofl0r/libperfstat
a tiny library to control what `perf record` records.
https://github.com/rofl0r/libperfstat
c perf performance-testing profiling record
Last synced: 12 months ago
JSON representation
a tiny library to control what `perf record` records.
- Host: GitHub
- URL: https://github.com/rofl0r/libperfstat
- Owner: rofl0r
- Created: 2024-03-17T01:10:30.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-17T01:14:37.000Z (over 2 years ago)
- Last Synced: 2025-06-20T15:49:05.402Z (about 1 year ago)
- Topics: c, perf, performance-testing, profiling, record
- Language: C
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
Awesome Lists containing this project
README
libperfstat - a tiny library to `perf record` only specific code parts
----------------------------------------------------------------------
# about
inspired by https://stackoverflow.com/questions/70314376/enable-disable-perf-event-collection-programmatically
i set out the implement the mentioned steps, only to find that the output
provided by `perf stat` wasn't quite what i wanted.
fortunately it turned out that `perf record` achieved the same IPC functionality
somewhere between kernel 5.4 and 5.10.
this library allows you to start `perf record` in the background, and
then enable and disable it programmatically, so you can performance-test
only specific code snippets and only in specific situations.
see `test.c` for how it works and how to use.
note that there's also a libperf - which let's you use the perf performance
counters manually without perf binary, a way more powerful tool.
however if a `perf report`-like output is what you're after, you'd probably
need to spend a week to study the perf code to figure out how to produce a
similar result.
# requirements
- gnu make
- a C compiler
- an installed `perf` binary that supports --control command line option.
one compiled from kernel sources >= 5.10 should work.
- this also means you need linux, since it's the platform perf was
written for.
# compilation/installation
make CFLAGS="-O1 -g"
make PREFIX=/usr install