diff options
Diffstat (limited to 'example')
-rw-r--r-- | example/counting.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/example/counting.cc b/example/counting.cc new file mode 100644 index 0000000..a2af7f9 --- /dev/null +++ b/example/counting.cc @@ -0,0 +1,21 @@ +#include <linux/perf_event.h> +#include "perf.hpp" + +int main() { + perf_group pg({ + {.name = "CPUCLK", + .type = PERF_TYPE_SOFTWARE, + .config = PERF_COUNT_SW_CPU_CLOCK}, + {.name = "TASK", + .type = PERF_TYPE_SOFTWARE, + .config = PERF_COUNT_SW_TASK_CLOCK}, + {.name = "INSN", + .type = PERF_TYPE_HARDWARE, + .config = PERF_COUNT_HW_INSTRUCTIONS}, + }); + pg.start(); + asm volatile("nop"); + asm volatile("nop"); + pg.stop(); + pg.dump(); +} |