Repository: google/benchmark
File: src/benchmark.cc (C++)

Code before:
  bool display_report_aggregates_only;
  bool file_report_aggregates_only;
};

RunResults RunBenchmark(
    const benchmark::internal::Benchmark::Instance& b,
    std::vector<BenchmarkReporter::Run>* complexity_reports) {
  RunResults run_results;

  const bool has_explicit_iteration_count = b.iterations != 0;
  size_t iters = has_explicit_iteration_count ? b.iterations : 1;
  std::unique_ptr<internal::ThreadManager> manager;
  std::vector<std::thread> pool(b.threads - 1);
  const int repeats =
      b.repetitions != 0 ? b.repetitions : FLAGS_benchmark_repetitions;
  run_results.display_report_aggregates_only =
      repeats != 1 && (b.aggregation_report_mode == internal::ARM_Unspecified
                           ? FLAGS_benchmark_report_aggregates_only ||
                                 FLAGS_benchmark_display_aggregates_only
                           : b.aggregation_report_mode &
                                 internal::ARM_DisplayReportAggregatesOnly);
  run_results.file_report_aggregates_only =
      repeats != 1 && (b.aggregation_report_mode == internal::ARM_Unspecified
                           ? FLAGS_benchmark_report_aggregates_only
                           : b.aggregation_report_mode &
                                 internal::ARM_FileReportAggregatesOnly);
  for (int repetition_num = 0; repetition_num < repeats; repetition_num++) {
    for (;;) {
      // Try benchmark
      VLOG(2) << "Running " << b.name << " for " << iters << "\n";

      manager.reset(new internal::ThreadManager(b.threads));
      for (std::size_t ti = 0; ti < pool.size(); ++ti) {
        pool[ti] = std::thread(&RunInThread, &b, iters,
                               static_cast<int>(ti + 1), manager.get());
      }
      RunInThread(&b, iters, 0, manager.get());
      manager->WaitForAllThreads();
      for (std::thread& thread : pool) thread.join();
      internal::ThreadManager::Result results;
      {
        MutexLock l(manager->GetBenchmarkMutex());
        results = manager->results;
      }
      manager.reset();
      // Adjust real/manual time stats since they were reported per thread.
      results.real_time_used /= b.threads;
      results.manual_time_used /= b.threads;

      VLOG(2) << "Ran in " << results.cpu_time_used << "/"
              << results.real_time_used << "\n";

Review comment (suggestion):
```c++
if (repeats != 1) {
  run_results.display_report_aggregates_only = (
      FLAGS_benchmark_report_aggregates_only || FLAGS_benchmark_display_aggregates_only);
  run_results.file_report_aggregates_only = FLAGS_benchmark_report_aggregates_only;
  if (b.aggregation_report_mode != internal::ARM_Unspecified) {
    run_results.display_report_aggregates_only = (
      b.aggregation_report_mode & internal::ARM_DisplayReportAggregatesOnly);
    run_results.file_report_aggregates_only = (
      b.aggregation_report_mode & internal::ARM_FileReportAggregatesOnly);
  }
}
```

a bit clearer than nested ternary operators, i think...

Code after:
  bool display_report_aggregates_only = false;
  bool file_report_aggregates_only = false;
};

RunResults RunBenchmark(
    const benchmark::internal::Benchmark::Instance& b,
    std::vector<BenchmarkReporter::Run>* complexity_reports) {
  RunResults run_results;

  const bool has_explicit_iteration_count = b.iterations != 0;
  size_t iters = has_explicit_iteration_count ? b.iterations : 1;
  std::unique_ptr<internal::ThreadManager> manager;
  std::vector<std::thread> pool(b.threads - 1);
  const int repeats =
      b.repetitions != 0 ? b.repetitions : FLAGS_benchmark_repetitions;
  if (repeats != 1) {
    run_results.display_report_aggregates_only =
        (FLAGS_benchmark_report_aggregates_only ||
         FLAGS_benchmark_display_aggregates_only);
    run_results.file_report_aggregates_only =
        FLAGS_benchmark_report_aggregates_only;
    if (b.aggregation_report_mode != internal::ARM_Unspecified) {
      run_results.display_report_aggregates_only =
          (b.aggregation_report_mode &
           internal::ARM_DisplayReportAggregatesOnly);
      run_results.file_report_aggregates_only =
          (b.aggregation_report_mode & internal::ARM_FileReportAggregatesOnly);
    }
  }
  for (int repetition_num = 0; repetition_num < repeats; repetition_num++) {
    for (;;) {
      // Try benchmark
      VLOG(2) << "Running " << b.name << " for " << iters << "\n";

      manager.reset(new internal::ThreadManager(b.threads));
      for (std::size_t ti = 0; ti < pool.size(); ++ti) {
        pool[ti] = std::thread(&RunInThread, &b, iters,
                               static_cast<int>(ti + 1), manager.get());
      }
      RunInThread(&b, iters, 0, manager.get());
      manager->WaitForAllThreads();
      for (std::thread& thread : pool) thread.join();
      internal::ThreadManager::Result results;
      {
        MutexLock l(manager->GetBenchmarkMutex());
        results = manager->results;
      }
      manager.reset();
      // Adjust real/manual time stats since they were reported per thread.
      results.real_time_used /= b.threads;
      results.manual_time_used /= b.threads;