diff --git a/ServerBench.cpp b/ServerBench.cpp index 833e909..3bb0d4d 100644 --- a/ServerBench.cpp +++ b/ServerBench.cpp @@ -228,11 +228,6 @@ private: return ret; } }; -#else -struct PerfCounter { - PerfCounter(int, int) {} - int64_t total() { return 0; } -}; #endif int main(int argc, char **argv) { @@ -247,6 +242,7 @@ int main(int argc, char **argv) { int metricsCount; cs.getMetricsV1(&metrics, &metricsCount); +#ifdef __linux__ PerfCounter instructions{PERF_TYPE_HARDWARE, PERF_COUNT_HW_INSTRUCTIONS}; PerfCounter cycles{PERF_TYPE_HARDWARE, PERF_COUNT_HW_CPU_CYCLES, "", instructions.getFd()}; @@ -288,6 +284,7 @@ int main(int argc, char **argv) { } } } +#endif auto w = std::thread{workload, &cs}; @@ -316,6 +313,7 @@ int main(int argc, char **argv) { "transactions_total "; body += std::to_string(transactions.load(std::memory_order_relaxed)); body += "\n"; +#ifdef __linux__ body += "# HELP instructions_total Total number of instructions\n" "# TYPE instructions_total counter\n" "instructions_total "; @@ -332,6 +330,7 @@ int main(int argc, char **argv) { body += "cache_event_total" + counter.getLabels() + " " + std::to_string(counter.total()) + "\n"; } +#endif for (int i = 0; i < metricsCount; ++i) { body += "# HELP ";