Add more perf counters
This commit is contained in:
@@ -175,7 +175,7 @@ double toSeconds(timeval t) {
|
||||
|
||||
#ifdef __linux__
|
||||
struct PerfCounter {
|
||||
explicit PerfCounter(int event) {
|
||||
PerfCounter(int type, int event) {
|
||||
struct perf_event_attr pe;
|
||||
|
||||
memset(&pe, 0, sizeof(pe));
|
||||
@@ -216,7 +216,7 @@ private:
|
||||
};
|
||||
#else
|
||||
struct PerfCounter {
|
||||
explicit PerPerfCounter(int) {}
|
||||
PerfCounter(int, int) {}
|
||||
int64_t total() { return 0; }
|
||||
};
|
||||
#endif
|
||||
@@ -233,8 +233,12 @@ int main(int argc, char **argv) {
|
||||
int metricsCount;
|
||||
cs.getMetricsV1(&metrics, &metricsCount);
|
||||
|
||||
PerfCounter instructions{PERF_COUNT_HW_INSTRUCTIONS};
|
||||
PerfCounter cycles{PERF_COUNT_HW_CPU_CYCLES};
|
||||
PerfCounter instructions{PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS};
|
||||
PerfCounter cycles{PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES};
|
||||
PerfCounter cacheRef{PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_REFERENCES};
|
||||
PerfCounter cacheMiss{PERF_TYPE_HARDWARE, PERF_COUNT_HW_CACHE_MISSES};
|
||||
PerfCounter branch{PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_INSTRUCTIONS};
|
||||
PerfCounter branchMiss{PERF_TYPE_HARDWARE, PERF_COUNT_HW_BRANCH_MISSES};
|
||||
auto w = std::thread{workload, &cs};
|
||||
|
||||
for (;;) {
|
||||
@@ -272,6 +276,26 @@ int main(int argc, char **argv) {
|
||||
"cycles_total ";
|
||||
body += std::to_string(cycles.total());
|
||||
body += "\n";
|
||||
body += "# HELP cache_references_total Total number of cache references\n"
|
||||
"# TYPE cache_references_total counter\n"
|
||||
"cache_references_total ";
|
||||
body += std::to_string(cacheRef.total());
|
||||
body += "\n";
|
||||
body += "# HELP cache_misses_total Total number of cache misses\n"
|
||||
"# TYPE cache_misses_total counter\n"
|
||||
"cache_misses_total ";
|
||||
body += std::to_string(cacheMiss.total());
|
||||
body += "\n";
|
||||
body += "# HELP branch_instructions_total Total number of branch "
|
||||
"instructions\n"
|
||||
"# TYPE branch_instructions_total counter\n"
|
||||
"branch_instructions_total ";
|
||||
body += std::to_string(branch.total());
|
||||
body += "\n";
|
||||
body += "# HELP branch_misses_total Total number of branch misses\n"
|
||||
"# TYPE branch_misses_total counter\n"
|
||||
"branch_misses_total ";
|
||||
body += std::to_string(branchMiss.total());
|
||||
|
||||
for (int i = 0; i < metricsCount; ++i) {
|
||||
body += "# HELP ";
|
||||
|
Reference in New Issue
Block a user