mirror of
https://github.com/google/benchmark.git
synced 2024-12-28 05:20:14 +08:00
376ebc2635
* Support optional, user-directed collection of performance counters The patch allows an engineer wishing to drill into the root causes of a regression, for example. Currently, only single threaded runs are supported. The feature is a build-time opt in, and then a runtime opt in. The engineer may run the benchmark executable, passing a list of performance counter names (using libpfm's naming scheme) at the command line. The counter values will then be collected and reported back as UserCounters. This is different from #240 in that it is a benchmark user opt-in, and the counter collection is transparent to the benchmark. Currently, this is only supported on platforms where libpfm is supported. libpfm: http://perfmon2.sourceforge.net/ * 'Use' values param in Snapshot when BENCHMARK_OS_WINDOWS This is to avoid unused parameter warning-as-error * Added missing include for <vector> in perf_counters.cc * Moved doc to docs * Added license blurbs
28 lines
650 B
C++
28 lines
650 B
C++
#undef NDEBUG
|
|
|
|
#include "../src/perf_counters.h"
|
|
|
|
#include "benchmark/benchmark.h"
|
|
#include "output_test.h"
|
|
|
|
void BM_Simple(benchmark::State& state) {
|
|
for (auto _ : state) {
|
|
benchmark::DoNotOptimize(state.iterations());
|
|
}
|
|
}
|
|
BENCHMARK(BM_Simple);
|
|
ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Simple\",$"}});
|
|
|
|
void CheckSimple(Results const& e) {
|
|
CHECK_COUNTER_VALUE(e, double, "CYCLES", GT, 0);
|
|
CHECK_COUNTER_VALUE(e, double, "BRANCHES", GT, 0.0);
|
|
}
|
|
CHECK_BENCHMARK_RESULTS("BM_Simple", &CheckSimple);
|
|
|
|
int main(int argc, char* argv[]) {
|
|
if (!benchmark::internal::PerfCounters::kSupported) {
|
|
return 0;
|
|
}
|
|
RunOutputTests(argc, argv);
|
|
}
|