Commit c5f238b1 by Eric Fiselier

Fix column width calculation and remove duplicate test

parent 4bf6ceb5
...@@ -802,26 +802,14 @@ void RunMatchingBenchmarks(const std::string& spec, ...@@ -802,26 +802,14 @@ void RunMatchingBenchmarks(const std::string& spec,
auto families = benchmark::internal::BenchmarkFamilies::GetInstance(); auto families = benchmark::internal::BenchmarkFamilies::GetInstance();
if (!families->FindBenchmarks(spec, &benchmarks)) return; if (!families->FindBenchmarks(spec, &benchmarks)) return;
// Determine the width of the name field using a minimum width of 10. // Determine the width of the name field using a minimum width of 10.
// Also determine max number of threads needed.
size_t name_field_width = 10; size_t name_field_width = 10;
for (const internal::Benchmark::Instance& benchmark : benchmarks) { for (const internal::Benchmark::Instance& benchmark : benchmarks) {
// Add width for _stddev and threads:XX name_field_width =
if (benchmark.threads > 1 && FLAGS_benchmark_repetitions > 1) { std::max<size_t>(name_field_width, benchmark.name.size());
name_field_width =
std::max<size_t>(name_field_width, benchmark.name.size() + 17);
} else if (benchmark.threads > 1) {
name_field_width =
std::max<size_t>(name_field_width, benchmark.name.size() + 10);
} else if (FLAGS_benchmark_repetitions > 1) {
name_field_width =
std::max<size_t>(name_field_width, benchmark.name.size() + 7);
} else {
name_field_width =
std::max<size_t>(name_field_width, benchmark.name.size());
}
} }
if (FLAGS_benchmark_repetitions > 1)
name_field_width += std::strlen("_stddev");
// Print header here // Print header here
BenchmarkReporter::Context context; BenchmarkReporter::Context context;
......
...@@ -58,17 +58,7 @@ static void BM_Factorial(benchmark::State& state) { ...@@ -58,17 +58,7 @@ static void BM_Factorial(benchmark::State& state) {
state.SetLabel(ss.str()); state.SetLabel(ss.str());
} }
BENCHMARK(BM_Factorial); BENCHMARK(BM_Factorial);
BENCHMARK(BM_Factorial)->UseRealTime();
static void BM_FactorialRealTime(benchmark::State& state) {
int fac_42 = 0;
while (state.KeepRunning())
fac_42 = Factorial(8);
// Prevent compiler optimizations
std::stringstream ss;
ss << fac_42;
state.SetLabel(ss.str());
}
BENCHMARK(BM_FactorialRealTime)->UseRealTime();
static void BM_CalculatePiRange(benchmark::State& state) { static void BM_CalculatePiRange(benchmark::State& state) {
double pi = 0.0; double pi = 0.0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment