On 2/20/15 4:26 PM, Benjamin Moody wrote:
I'm trying to write a program that uses the Linux perf event API to
track the CPU usage of an arbitrary task. I'm following the
documentation at <http://linux.die.net/man/2/perf_event_open>.
My program (highly simplified version shown below) seems to work most
of the time, and as far as I can tell, it should be measuring exactly
the same thing as what 'perf stat -e instructions:uD' measures.
However, when I try measuring the performance of a certain large
proprietary application, I get *completely* different results from my
program and from perf stat. (The results from perf are somewhat
believable; mine are not.)
Trying using a program with established results. e.g., This is from
PeterZ years ago. On intel 'perf stat -e instructions a.out' should show
~1 billion (a wee bit more, but clearly in the 1b range).
int main (void)
{
int i;
for (i = 0; i < 100000000; i++) {
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
}
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html