Refactor microbenchmarks
- Report CPU frequency only if it is successfully queried
PiperOrigin-RevId: 345756568
diff --git a/bench/prelu.cc b/bench/prelu.cc
index 7bed219..5c0700e 100644
--- a/bench/prelu.cc
+++ b/bench/prelu.cc
@@ -82,7 +82,10 @@
}
prelu_op = nullptr;
- state.counters["Freq"] = benchmark::utils::GetCurrentCpuFrequency();
+ const uint64_t cpu_frequency = benchmark::utils::GetCurrentCpuFrequency();
+ if (cpu_frequency != 0) {
+ state.counters["cpufreq"] = cpu_frequency;
+ }
const size_t elements_per_iteration = batch_size * height * width * channels;
state.counters["elements"] =
@@ -207,7 +210,10 @@
}
}
- state.counters["Freq"] = benchmark::utils::GetCurrentCpuFrequency();
+ const uint64_t cpu_frequency = benchmark::utils::GetCurrentCpuFrequency();
+ if (cpu_frequency != 0) {
+ state.counters["cpufreq"] = cpu_frequency;
+ }
const size_t elements_per_iteration = batch_size * height * width * channels;
state.counters["elements"] =