perf_counters_test.cc 664 B

123456789101112131415161718192021222324252627
  1. #undef NDEBUG
  2. #include "../src/perf_counters.h"
  3. #include "benchmark/benchmark.h"
  4. #include "output_test.h"
  5. static void BM_Simple(benchmark::State& state) {
  6. for (auto _ : state) {
  7. benchmark::DoNotOptimize(state.iterations());
  8. }
  9. }
  10. BENCHMARK(BM_Simple);
  11. ADD_CASES(TC_JSONOut, {{"\"name\": \"BM_Simple\",$"}});
  12. static void CheckSimple(Results const& e) {
  13. CHECK_COUNTER_VALUE(e, double, "CYCLES", GT, 0);
  14. CHECK_COUNTER_VALUE(e, double, "BRANCHES", GT, 0.0);
  15. }
  16. CHECK_BENCHMARK_RESULTS("BM_Simple", &CheckSimple);
  17. int main(int argc, char* argv[]) {
  18. if (!benchmark::internal::PerfCounters::kSupported) {
  19. return 0;
  20. }
  21. RunOutputTests(argc, argv);
  22. }