Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Nov 2009
Using linux performance counters from within application
Specifically, my goal is to profile only a portion of code, and trigger the beginning and end of the measurement from calls within the code. It seems that the perf tool is really just a wrapper for calling the sys_perf_event_open system call, so I assume that I probably want to call this directly from my code, but I haven't been able to find any decent documentation on that particular system call.
Does anyone know where I can find some documentation? Or is there perhaps a better way to go about this? The particular event counters I want (to start with at least) are the instruction count, cache miss counts, tlb misses, branch mispredictions, and malloc calls.
- Join Date
- Apr 2009
- I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
There is a gcc flag which will cause the compiler to emit pre-processed code when it compiles, which should have the profiler calls embedded. You should be able to use that to figure out how to manually embed them in your code. The flag is -E. From the gcc man page:
-E Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!