top | item 9784518

Show HN: Prof – Self-contained C/C++ profiler library for Linux

22 points| cyrusand | 10 years ago |github.com | reply

2 comments

order
[+] johnmarinelli|10 years ago|reply
Should I be able to simply #include "prof.h" and use it? I tried the first example, but I'm getting this error:

# prof.h:274: PROF error (Invalid argument) Aborted (core dumped)

running through gdb gives me: Starting program: /home/john/Documents/c++/tmp/prof/a # prof.h:274: PROF error (Invalid argument)

Program received signal SIGABRT, Aborted. 0x00007ffff7745cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56 56 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.

On Ubuntu 14.04, gcc 4.8.4.

[+] cyrusand|10 years ago|reply
Yes, including "prof.h" is enough, but you can try using different events, by default Prof uses `PERF_COUNT_HW_REF_CPU_CYCLES`. For example try defining before #include "prof.h":

#define PROF_EVENT_LIST PROF_EVENT_HW(CPU_CYCLES)

or

#define PROF_EVENT_LIST PROF_EVENT_SW(CPU_CLOCK)

Which kernel version are you running? Are you running this from a virtual machine?

Feel free to open an issue (https://github.com/cyrus-and/prof/issues) with these information if you can't manage to make it work.