1
0
mirror of https://github.com/google/benchmark.git synced 2025-04-29 06:20:32 +08:00

Fix column width calculation and remove duplicate test

This commit is contained in:
Eric Fiselier 2015-03-27 12:28:22 -04:00
parent 4bf6ceb50d
commit c5f238b18c
2 changed files with 5 additions and 27 deletions

View File

@ -802,26 +802,14 @@ void RunMatchingBenchmarks(const std::string& spec,
auto families = benchmark::internal::BenchmarkFamilies::GetInstance();
if (!families->FindBenchmarks(spec, &benchmarks)) return;
// 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;
for (const internal::Benchmark::Instance& benchmark : benchmarks) {
// Add width for _stddev and threads:XX
if (benchmark.threads > 1 && FLAGS_benchmark_repetitions > 1) {
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());
}
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
BenchmarkReporter::Context context;

View File

@ -58,17 +58,7 @@ static void BM_Factorial(benchmark::State& state) {
state.SetLabel(ss.str());
}
BENCHMARK(BM_Factorial);
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();
BENCHMARK(BM_Factorial)->UseRealTime();
static void BM_CalculatePiRange(benchmark::State& state) {
double pi = 0.0;