From d75d24384221147d2dd6b52868e73c551fec4308 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Wed, 2 Oct 2024 21:34:05 +0200 Subject: initial commit of libperf --- example/counting.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 example/counting.cc (limited to 'example') 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 +#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(); +} -- cgit v1.2.3