Xara
Xara

Reputation: 9108

Valgrind : Commands to get memory access, cycles and instructions executed

Which commands and tools of valgrind will help me to get the following statistics on linux.

Number of (CPU) instructions executed Number of cycles Number of memory accesses

By reading I have come to know that cachegrind and callgrind can help me for the above tasks but which command will help me to do so.

Upvotes: 0

Views: 693

Answers (1)

K-J
K-J

Reputation: 586

Just type:

valgrind --tool=cachegrind ./program

I.e. use cachegrind. It will print out number of instructions and memory accesses, accompanied with read/write misses of the same. If you need function-specific values, type:

cg_annotate --show=Ir,Dr,Dw cachegrind.out.<PID>

cachegrind.out. is the file that was created when you ran the first command and PID is the process ID. The "--show" option is not essential, it just restricts the output to the memory and instruction accesses that you seem to be intrested in.

Upvotes: 1

Related Questions