diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-10-04 19:10:04 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-10-04 19:10:04 +0200 |
commit | 28372905a333f0678b836f6f289ad546f758103c (patch) | |
tree | 4d963ed0d9c17d42431f688d13056ba156e5f8ad /example | |
parent | 751fc86a8826b3af827a83629309e399788a1bad (diff) | |
download | libperf-28372905a333f0678b836f6f289ad546f758103c.tar.gz libperf-28372905a333f0678b836f6f289ad546f758103c.zip |
Diffstat (limited to 'example')
-rw-r--r-- | example/counting.cc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/example/counting.cc b/example/counting.cc index a2af7f9..5d086f6 100644 --- a/example/counting.cc +++ b/example/counting.cc @@ -1,18 +1,16 @@ -#include <linux/perf_event.h> #include "perf.hpp" +#include <cstdio> + 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}, - }); + perf_group pg({PMC_CPU_CLK, PMC_TASK_CLK, PMC_INSN, PMC_CYCLES}); + + std::puts("- start-stop-dump"); + pg.start(); + pg.stop(); + pg.dump(); + + std::puts("- start-2nop-stop-dump"); pg.start(); asm volatile("nop"); asm volatile("nop"); |