summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-10-04 19:10:04 +0200
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-10-04 19:10:04 +0200
commit28372905a333f0678b836f6f289ad546f758103c (patch)
tree4d963ed0d9c17d42431f688d13056ba156e5f8ad /example
parent751fc86a8826b3af827a83629309e399788a1bad (diff)
downloadlibperf-main.tar.gz
libperf-main.zip
move pmc descriptors into own headerHEADmain
Diffstat (limited to 'example')
-rw-r--r--example/counting.cc22
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");