17 #include "benchmark/benchmark.h"
21 #ifndef BENCHMARK_OS_WINDOWS
22 #ifndef BENCHMARK_OS_FUCHSIA
23 #include <sys/resource.h>
31 #include <condition_variable>
89 if (
b.use_manual_time()) {
101 if (memory_iterations > 0) {
104 memory_iterations ?
static_cast<double>(memory_result.
num_allocs) /
122 b->measure_process_cpu_time()
128 <<
"Benchmark returned before State::KeepRunning() returned false!";
148 reports_for_family(reports_for_family_),
149 min_time(!
IsZero(
b.min_time()) ?
b.min_time() : FLAGS_benchmark_min_time),
150 repeats(
b.repetitions() != 0 ?
b.repetitions()
151 : FLAGS_benchmark_repetitions),
152 has_explicit_iteration_count(
b.iterations() != 0),
154 iters(has_explicit_iteration_count ?
b.iterations() : 1),
155 perf_counters_measurement(
157 perf_counters_measurement_ptr(perf_counters_measurement.IsValid()
158 ? &perf_counters_measurement
161 (FLAGS_benchmark_report_aggregates_only ||
162 FLAGS_benchmark_display_aggregates_only);
164 FLAGS_benchmark_report_aggregates_only;
171 BM_CHECK(FLAGS_benchmark_perf_counters.empty() ||
173 <<
"Perf counters were requested but could not be set up.";
180 std::unique_ptr<internal::ThreadManager> manager;
184 for (std::size_t
ti = 0;
ti <
pool.size(); ++
ti) {
194 manager->WaitForAllThreads();
200 MutexLock l(manager->GetBenchmarkMutex());
201 i.results = manager->results;
209 i.results.manual_time_used /=
b.
threads();
213 BM_VLOG(2) <<
"Ran in " <<
i.results.cpu_time_used <<
"/"
214 <<
i.results.real_time_used <<
"\n";
221 i.seconds =
i.results.cpu_time_used;
223 i.seconds =
i.results.manual_time_used;
225 i.seconds =
i.results.real_time_used;
241 bool is_significant = (
i.seconds /
min_time) > 0.1;
242 multiplier = is_significant ? multiplier : 10.0;
246 std::lround(
std::max(multiplier *
static_cast<double>(
i.iters),
247 static_cast<double>(
i.iters) + 1.0)));
251 BM_VLOG(3) <<
"Next iters: " << next_iters <<
", " << multiplier <<
"\n";
260 return i.results.has_error_ ||
261 i.iters >= kMaxIterations ||
289 const bool results_are_significant = !is_the_first_repetition ||
293 if (results_are_significant)
break;
300 "if we did more iterations than we want to do the next time, "
301 "then we should have accepted the current iteration run.");
310 memory_iterations = std::min<IterationCount>(16,
iters);
312 std::unique_ptr<internal::ThreadManager> manager;
314 RunInThread(&
b, memory_iterations, 0, manager.get(),
316 manager->WaitForAllThreads();
324 CreateRunReport(
b,
i.results, memory_iterations, memory_result,
i.seconds,