diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-10-02 21:34:05 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-10-02 21:34:05 +0200 |
commit | d75d24384221147d2dd6b52868e73c551fec4308 (patch) | |
tree | a8448a8d756fc63cfe5bdc1c91eb8689bdc4b31e /example | |
download | libperf-d75d24384221147d2dd6b52868e73c551fec4308.tar.gz libperf-d75d24384221147d2dd6b52868e73c551fec4308.zip |
initial commit of libperf
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(); +} |