Simple PMU

Simple PMU is simple way to count cycles (and a few other events) inside programs on Intel x86 CPUs. It aims to be a replacement for RDTSC, which is not really reliable anymore on modern systems due to Turbo mode and cpu frequency scaling. See this presentation for an tutorial. For more details see the manual.

Getting simple-pmu

git clone git://
cd simple-pmu
make		(or make KDIR=/your/kernel/source)
insmod simple-pmu
Simple PMU is a external kernel module and may need minor porting for newer kernel versions.

Using simple-pmu

Simple example:
44 #define _GNU_SOURCE 1
45 ...
46 #include "cycles.h"
48 ...
50 counter_t a, b;
52 pin_cpu(NULL);
53 if (perfmon_available() == 0) ... exit...
55 sync_core();
56 a = unhalted_core();
58 b = unhalted_core();
59 sync_core();
60 printf("%llu cycles\n", b - a);


git tree