Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I count instructions executed on Red Hat Enterprise Linux (x86-64)?

I want to find out how many x86-64 instructions are executed during a given run of a program running on Red Hat Enterprise Linux. I know I can get this information from valgrind but the slowdown is considerable. I also know that we are using Intel Core 2 Quad CPUs (model Q6700) which have hardware performance counters built in. But I don't know of any way to get access to the total number of instructions executed from within a C program.

like image 325
Norman Ramsey Avatar asked Nov 17 '10 02:11

Norman Ramsey


1 Answers

Performance Application Programming Interface (PAPI) appears to be along the lines of what you are looking for.

From the website:

PAPI aims to provide the tool designer and application engineer with a consistent interface and methodology for use of the performance counter hardware found in most major microprocessors.

Vince Weaver, a Post Doctoral Research Associate with the Innovative Computing Laboratory at the University of Tennessee, did some PAPI-related work. The research listed on his web page at UTK looks like it may provide some additional information.

like image 57
jschmier Avatar answered Sep 19 '22 23:09

jschmier