summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
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");