Harness the power of performance counters, akin to tools like perf, but scoped within your C++ applications. This project provides a seamless way to measure and analyze performance metrics within defined scopes.
- Only limited to the
perf_hw_idGeneralized performance event (More coming soon).
#include "PerfScope.h"
int main() {
volatile uint64_t x = 0;
{
auto tmp = PerfScope<
PERF_COUNT_HW_CACHE_REFERENCES,
PERF_COUNT_HW_CACHE_MISSES,
PERF_COUNT_HW_BRANCH_INSTRUCTIONS,
PERF_COUNT_HW_BRANCH_MISSES>();
for(int i = 0; i < 100000; i++){
x+=i;
}
}
return 0;
}3771
2433
110931
657