Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pwaller/perf
Linux Perf subsystem bindings for Go
https://github.com/pwaller/perf
benchmark cpu-monitoring cpu-profiling go linux linux-perf-bindings perf profiling
Last synced: 4 days ago
JSON representation
Linux Perf subsystem bindings for Go
- Host: GitHub
- URL: https://github.com/pwaller/perf
- Owner: pwaller
- License: bsd-3-clause
- Created: 2016-12-21T17:42:14.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T12:49:08.000Z (over 4 years ago)
- Last Synced: 2024-06-20T03:44:24.354Z (4 months ago)
- Topics: benchmark, cpu-monitoring, cpu-profiling, go, linux, linux-perf-bindings, perf, profiling
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 21
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Defunct
These bindings are defunct. Please see acln0's great efforts, which hopefully will end up under the golang.org/x namespace one day:
https://github.com/acln0/perf
# Linux Perf Bindings for Go
If you'd like to measure the (close to) exact number of CPU cycles and misses of a specific piece of Go code, you've come to the right place!
Unfortunately, it is not possible for a program being profiled by perf to exclude all but a specific bit of code. The linux documentation seems to imply that this can be achieved with `prctl`, but there are mailing list posts indicating that this does not work.
The solution is to profiling a specific section of code is to "self profile", which is that a program should configure and read the linux counters itself. In this case, `prctl(PR_TASK_PERF_EVENTS_DISABLE)` and `prctl(PR_TASK_PERF_EVENTS_ENABLE)` work as expected.
I'm afraid the code is very rough and ready at the moment. If you want to use it, you should figure it out by reading the source and the Linux documentation for the perf counters. Generally, you should only use this if you know what you're doing, otherwise you are likely to get bogus results.
Help is welcomed.