Report 1ns instead of 0ns for probe_benchmarks. Some tools incorrectly assume that benchmark was not run if 0ns reported. PiperOrigin-RevId: 852831533 Change-Id: Ibf2e60dcb308928358ddf80dc4d2f7eda8a78530
diff --git a/absl/container/internal/raw_hash_set_probe_benchmark.cc b/absl/container/internal/raw_hash_set_probe_benchmark.cc index a09f7d9..7165558 100644 --- a/absl/container/internal/raw_hash_set_probe_benchmark.cc +++ b/absl/container/internal/raw_hash_set_probe_benchmark.cc
@@ -556,9 +556,11 @@ // Check the regex again. We might had have enabled only one of the // stats for the benchmark. if (!CanRunBenchmark(name)) return; + // Report at least 1, because benchy drops results with zero. + double reported_value = std::max(1e9 * result.ratios.*val, 1.0); absl::PrintF(" %s{\n", comma); - absl::PrintF(" \"cpu_time\": %f,\n", 1e9 * result.ratios.*val); - absl::PrintF(" \"real_time\": %f,\n", 1e9 * result.ratios.*val); + absl::PrintF(" \"cpu_time\": %f,\n", reported_value); + absl::PrintF(" \"real_time\": %f,\n", reported_value); absl::PrintF(" \"iterations\": 1,\n"); absl::PrintF(" \"name\": \"%s\",\n", name); absl::PrintF(" \"time_unit\": \"ns\"\n");