Skip to content

Commit b086a63

Browse files
committed
Reformat thanks to clang format.
1 parent 32afbca commit b086a63

File tree

6 files changed

+51
-35
lines changed

6 files changed

+51
-35
lines changed

include/benchmark/benchmark.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ template <class Q> int BM_Sequential(benchmark::State& state) {
126126
}
127127
BENCHMARK_TEMPLATE(BM_Sequential, WaitQueue<int>)->Range(1<<0, 1<<10);
128128
129-
Use `Benchmark::MinTime(double t)` to set the minimum time used to determine how long
130-
to run the benchmark. This option overrides the `benchmark_min_time` flag.
129+
Use `Benchmark::MinTime(double t)` to set the minimum time used to determine how
130+
long to run the benchmark. This option overrides the `benchmark_min_time` flag.
131131
132-
If a benchmark measures time manually, use `Benchmark::MinRelAccuracy(double r)` to set
133-
the required minimum relative accuracy used to determine how long to run the benchmark.
134-
This option overrides the `benchmark_min_rel_accuracy` flag.
132+
If a benchmark measures time manually, use `Benchmark::MinRelAccuracy(double r)`
133+
to set the required minimum relative accuracy used to determine how long to run
134+
the benchmark. This option overrides the `benchmark_min_rel_accuracy` flag.
135135
136136
void BM_test(benchmark::State& state) {
137137
... body ...
@@ -1208,8 +1208,8 @@ class BENCHMARK_EXPORT Benchmark {
12081208
// the `benchmark_min_rel_accuracy` flag.
12091209
// REQUIRES: `r > 0`, `Iterations` has not been called on this benchmark, and
12101210
// time is measured manually, i.e., `UseManualTime` has been called on this
1211-
// benchmark and each benchmark iteration should call `SetIterationTime(seconds)`
1212-
// to report the measured time.
1211+
// benchmark and each benchmark iteration should call
1212+
// `SetIterationTime(seconds)` to report the measured time.
12131213
Benchmark* MinRelAccuracy(double r);
12141214

12151215
// Set the minimum amount of time to run the benchmark before taking runtimes

src/benchmark.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ BM_DEFINE_bool(benchmark_list_tests, false);
6565
// linked into the binary are run.
6666
BM_DEFINE_string(benchmark_filter, "");
6767

68-
// Specification of either an exact number of iterations (specified as `<integer>x`)
69-
// or a minimum number of seconds (specified as `<float>s`) used to determine how
70-
// long to run the benchmark.
68+
// Specification of either an exact number of iterations (specified as
69+
// `<integer>x`) or a minimum number of seconds (specified as `<float>s`) used
70+
// to determine how long to run the benchmark.
7171
//
72-
// If the latter format (ie., min seconds) is used, the system may run the benchmark longer
73-
// until the results are considered significant.
72+
// If the latter format (ie., min seconds) is used, the system may run
73+
// the benchmark longer until the results are considered significant.
7474
//
7575
// For backward compatibility, the `s` suffix may be omitted, in which case,
7676
// the specified number is interpreted as the number of seconds.

src/benchmark_api_internal.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ BenchmarkInstance::BenchmarkInstance(Benchmark* benchmark, int family_idx,
5353
}
5454

5555
if (!IsZero(benchmark->min_rel_accuracy_)) {
56-
name_.min_rel_accuracy = StrFormat("min_rel_accuracy:%0.3f", benchmark_.min_rel_accuracy_);
56+
name_.min_rel_accuracy =
57+
StrFormat("min_rel_accuracy:%0.3f", benchmark_.min_rel_accuracy_);
5758
}
5859

5960
if (!IsZero(benchmark->min_warmup_time_)) {

src/benchmark_runner.cc

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ BenchmarkRunner::BenchmarkRunner(
228228
reports_for_family(reports_for_family_),
229229
parsed_benchtime_flag(ParseBenchMinTime(FLAGS_benchmark_min_time)),
230230
min_time(ComputeMinTime(b, parsed_benchtime_flag)),
231-
min_rel_accuracy(!IsZero(b.min_rel_accuracy())
232-
? b.min_rel_accuracy()
233-
: FLAGS_benchmark_min_rel_accuracy),
231+
min_rel_accuracy(!IsZero(b.min_rel_accuracy())
232+
? b.min_rel_accuracy()
233+
: FLAGS_benchmark_min_rel_accuracy),
234234
min_warmup_time((!IsZero(b.min_time()) && b.min_warmup_time() > 0.0)
235235
? b.min_warmup_time()
236236
: FLAGS_benchmark_min_warmup_time),
@@ -332,7 +332,8 @@ IterationCount BenchmarkRunner::PredictNumItersNeeded(
332332
multiplier = is_significant ? multiplier : 10.0;
333333

334334
if (!IsZero(GetMinRelAccuracy())) {
335-
multiplier = std::max(multiplier, GetRelAccuracy(i) * 1.4 / GetMinRelAccuracy());
335+
multiplier =
336+
std::max(multiplier, GetRelAccuracy(i) * 1.4 / GetMinRelAccuracy());
336337
}
337338

338339
// So what seems to be the sufficiently-large iteration count? Round up.
@@ -354,9 +355,10 @@ bool BenchmarkRunner::ShouldReportIterationResults(
354355
return i.results.skipped_ ||
355356
// Too many iterations already.
356357
i.iters >= kMaxIterations ||
357-
// We have applied for enough time and the relative accuracy is good enough.
358-
// Relative accuracy is checked only for user provided timers.
359-
(HasSufficientTimeToApply(i) && (!b.use_manual_time() || HasSufficientRelAccuracy(i)));
358+
// We have applied for enough time and the relative accuracy is good
359+
// enough. Relative accuracy is checked only for user provided timers.
360+
(HasSufficientTimeToApply(i) &&
361+
(!b.use_manual_time() || HasSufficientRelAccuracy(i)));
360362
}
361363

362364
double BenchmarkRunner::GetMinTimeToApply() const {
@@ -369,19 +371,25 @@ double BenchmarkRunner::GetMinTimeToApply() const {
369371
}
370372

371373
double BenchmarkRunner::GetRelAccuracy(const IterationResults& i) const {
372-
return std::sqrt(i.seconds_pow2 / i.iters - std::pow(i.seconds / i.iters, 2.)) / (i.seconds / i.iters) / sqrt(i.iters);
374+
return std::sqrt(i.seconds_pow2 / i.iters -
375+
std::pow(i.seconds / i.iters, 2.)) /
376+
(i.seconds / i.iters) / sqrt(i.iters);
373377
}
374378

375-
bool BenchmarkRunner::HasSufficientTimeToApply(const IterationResults& i) const {
379+
bool BenchmarkRunner::HasSufficientTimeToApply(
380+
const IterationResults& i) const {
376381
return i.seconds >= GetMinTimeToApply() ||
377382
// CPU time is specified but the elapsed real time greatly exceeds
378383
// the minimum time.
379384
// Note that user provided timers are except from this test.
380-
(!b.use_manual_time() && i.results.real_time_used >= 5 * GetMinTimeToApply());
385+
(!b.use_manual_time() &&
386+
i.results.real_time_used >= 5 * GetMinTimeToApply());
381387
}
382388

383-
bool BenchmarkRunner::HasSufficientRelAccuracy(const IterationResults& i) const {
384-
return (IsZero(GetMinRelAccuracy()) || (GetRelAccuracy(i) <= GetMinRelAccuracy()));
389+
bool BenchmarkRunner::HasSufficientRelAccuracy(
390+
const IterationResults& i) const {
391+
return (IsZero(GetMinRelAccuracy()) ||
392+
(GetRelAccuracy(i) <= GetMinRelAccuracy()));
385393
}
386394

387395
void BenchmarkRunner::FinishWarmUp(const IterationCount& i) {

src/thread_timer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class ThreadTimer {
3939

4040
// Called by each thread
4141
void SetIterationTime(double seconds) {
42-
manual_time_used_ += seconds;
43-
manual_time_used_pow2_ += std::pow(seconds, 2.);
42+
manual_time_used_ += seconds;
43+
manual_time_used_pow2_ += std::pow(seconds, 2.);
4444
}
4545

4646
bool running() const { return running_; }

test/benchmark_min_rel_accuracy_flag_test.cc

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "benchmark/benchmark.h"
1010

11-
// Tests that if a benchmark measures time manually, we can specify the required relative accuracy with
12-
// --benchmark_min_rel_accuracy=<min_rel_accuracy>.
11+
// Tests that if a benchmark measures time manually, we can specify the required
12+
// relative accuracy with --benchmark_min_rel_accuracy=<min_rel_accuracy>.
1313
namespace {
1414

1515
class TestReporter : public benchmark::ConsoleReporter {
@@ -22,7 +22,8 @@ class TestReporter : public benchmark::ConsoleReporter {
2222
assert(report.size() == 1);
2323
iters_.push_back(report[0].iterations);
2424
real_accumulated_times_.push_back(report[0].real_accumulated_time);
25-
manual_accumulated_time_pow2s_.push_back(report[0].manual_accumulated_time_pow2);
25+
manual_accumulated_time_pow2s_.push_back(
26+
report[0].manual_accumulated_time_pow2);
2627
ConsoleReporter::ReportRuns(report);
2728
};
2829

@@ -61,7 +62,8 @@ static void BM_MyBench(benchmark::State& state) {
6162
BENCHMARK(BM_MyBench)->UseManualTime();
6263

6364
int main(int argc, char** argv) {
64-
// Make a fake argv and append the new --benchmark_min_rel_accuracy=<min_rel_accuracy> to it.
65+
// Make a fake argv and append the new
66+
// --benchmark_min_rel_accuracy=<min_rel_accuracy> to it.
6567
int fake_argc = argc + 2;
6668
const char** fake_argv = new const char*[static_cast<size_t>(fake_argc)];
6769
for (int i = 0; i < argc; ++i) fake_argv[i] = argv[i];
@@ -77,10 +79,15 @@ int main(int argc, char** argv) {
7779

7880
// Check the executed iters.
7981
const benchmark::IterationCount iters = test_reporter.GetIters()[0];
80-
const double real_accumulated_time = test_reporter.GetRealAccumulatedTimes()[0];
81-
const double manual_accumulated_time_pow2 = test_reporter.GetManualAccumulatedTimePow2s()[0];
82-
83-
const double rel_accuracy = std::sqrt(manual_accumulated_time_pow2 / iters - std::pow(real_accumulated_time / iters, 2.)) / (real_accumulated_time / iters) / sqrt(iters);
82+
const double real_accumulated_time =
83+
test_reporter.GetRealAccumulatedTimes()[0];
84+
const double manual_accumulated_time_pow2 =
85+
test_reporter.GetManualAccumulatedTimePow2s()[0];
86+
87+
const double rel_accuracy =
88+
std::sqrt(manual_accumulated_time_pow2 / iters -
89+
std::pow(real_accumulated_time / iters, 2.)) /
90+
(real_accumulated_time / iters) / sqrt(iters);
8491
assert(rel_accuracy <= 0.01);
8592

8693
delete[] fake_argv;

0 commit comments

Comments
 (0)