From 290bd60289ef571875415cf82be805f9a446c6a9 Mon Sep 17 00:00:00 2001 From: Ismael Date: Sat, 21 May 2016 11:51:42 +0200 Subject: [PATCH] Refactor for pull request --- AUTHORS | 1 + CONTRIBUTORS | 1 + include/benchmark/benchmark_api.h | 7 ++++--- include/benchmark/reporter.h | 2 +- src/minimal_leastsq.cc | 2 +- src/minimal_leastsq.h | 4 ++-- src/reporter.cc | 4 ++-- test/complexity_test.cc | 12 ++++++------ 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/AUTHORS b/AUTHORS index 9da43c73..7ddffd8c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -16,6 +16,7 @@ Eugene Zhuk Evgeny Safronov Felix Homann Google Inc. +Ismael Jimenez Martinez JianXiong Zhou Jussi Knuuttila Kaito Udagawa diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 67ecb280..a575ef1b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -31,6 +31,7 @@ Dominic Hamon Eugene Zhuk Evgeny Safronov Felix Homann +Ismael Jimenez Martinez JianXiong Zhou Jussi Knuuttila Kaito Udagawa diff --git a/include/benchmark/benchmark_api.h b/include/benchmark/benchmark_api.h index 146a8cc8..d7cf83f6 100644 --- a/include/benchmark/benchmark_api.h +++ b/include/benchmark/benchmark_api.h @@ -232,7 +232,8 @@ enum TimeUnit { }; // BigO is passed to a benchmark in order to specify the asymptotic computational -// complexity for the benchmark. +// complexity for the benchmark. In case O_Auto is selected, complexity will be +// calculated automatically to the best fit. enum BigO { O_None, O_1, @@ -479,8 +480,8 @@ public: // or MB/second values. Benchmark* UseManualTime(); - // Set the asymptotic computational complexity for the benchmark. This option - // called the asymptotic computational complexity will be shown on the output. + // Set the asymptotic computational complexity for the benchmark. If called + // the asymptotic computational complexity will be shown on the output. Benchmark* Complexity(BigO complexity); // Support for running multiple copies of the same benchmark concurrently diff --git a/include/benchmark/reporter.h b/include/benchmark/reporter.h index 24c26919..d6b713a4 100644 --- a/include/benchmark/reporter.h +++ b/include/benchmark/reporter.h @@ -74,7 +74,7 @@ class BenchmarkReporter { int arg1; int arg2; - // Inform print function if the current run is a complexity report + // Inform print function whether the current run is a complexity report bool report_bigO; bool report_rms; }; diff --git a/src/minimal_leastsq.cc b/src/minimal_leastsq.cc index 32d27455..07a47b99 100644 --- a/src/minimal_leastsq.cc +++ b/src/minimal_leastsq.cc @@ -13,7 +13,7 @@ // limitations under the License. // Source project : https://github.com/ismaelJimenez/cpp.leastsq -// Addapted to be used with google benchmark +// Adapted to be used with google benchmark #include "minimal_leastsq.h" diff --git a/src/minimal_leastsq.h b/src/minimal_leastsq.h index d0d58223..0b137fb7 100644 --- a/src/minimal_leastsq.h +++ b/src/minimal_leastsq.h @@ -13,7 +13,7 @@ // limitations under the License. // Source project : https://github.com/ismaelJimenez/cpp.leastsq -// Addapted to be used with google benchmark +// Adapted to be used with google benchmark #if !defined(MINIMAL_LEASTSQ_H_) #define MINIMAL_LEASTSQ_H_ @@ -22,7 +22,7 @@ #include -// This data structure will contain the result returned vy minimalLeastSq +// This data structure will contain the result returned by minimalLeastSq // - coef : Estimated coeficient for the high-order term as interpolated from data. // - rms : Normalized Root Mean Squared Error. // - complexity : Scalability form (e.g. O_N, O_N_log_N). In case a scalability form has been provided to minimalLeastSq diff --git a/src/reporter.cc b/src/reporter.cc index da40db61..61a6d5c3 100644 --- a/src/reporter.cc +++ b/src/reporter.cc @@ -85,11 +85,11 @@ void BenchmarkReporter::ComputeBigO( CHECK(reports.size() >= 2) << "Cannot compute asymptotic complexity for less than 2 reports"; // Accumulators. std::vector N; - std::vector RealTime; + std::vector RealTime; std::vector CpuTime; // Populate the accumulators. - for (Run const& run : reports) { + for (const Run& run : reports) { N.push_back(run.arg1); RealTime.push_back(run.real_accumulated_time/run.iterations); CpuTime.push_back(run.cpu_accumulated_time/run.iterations); diff --git a/test/complexity_test.cc b/test/complexity_test.cc index 321fdadb..e7e16d31 100644 --- a/test/complexity_test.cc +++ b/test/complexity_test.cc @@ -36,8 +36,8 @@ static void BM_Complexity_O_N(benchmark::State& state) { benchmark::DoNotOptimize(std::find(v.begin(), v.end(), itemNotInVector)); } } -BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2)->Range(1<<10, 1<<16) -> Complexity(benchmark::O_N); -BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2)->Range(1<<10, 1<<16) -> Complexity(benchmark::O_Auto); +BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::O_N); +BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::O_Auto); static void BM_Complexity_O_N_Squared(benchmark::State& state) { std::string s1(state.range_x(), '-'); @@ -77,7 +77,7 @@ static void BM_Complexity_O_log_N(benchmark::State& state) { } } BENCHMARK(BM_Complexity_O_log_N) - ->RangeMultiplier(2)->Range(1<<10, 1<<16) -> Complexity(benchmark::O_log_N); + -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::O_log_N); static void BM_Complexity_O_N_log_N(benchmark::State& state) { auto v = ConstructRandomVector(state.range_x()); @@ -85,8 +85,8 @@ static void BM_Complexity_O_N_log_N(benchmark::State& state) { std::sort(v.begin(), v.end()); } } -BENCHMARK(BM_Complexity_O_N_log_N) ->RangeMultiplier(2)->Range(1<<10, 1<<16) -> Complexity(benchmark::O_N_log_N); -BENCHMARK(BM_Complexity_O_N_log_N) ->RangeMultiplier(2)->Range(1<<10, 1<<16) -> Complexity(benchmark::O_Auto); +BENCHMARK(BM_Complexity_O_N_log_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::O_N_log_N); +BENCHMARK(BM_Complexity_O_N_log_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::O_Auto); // Test benchmark with no range and check no complexity is calculated. void BM_Extreme_Cases(benchmark::State& state) { @@ -94,6 +94,6 @@ void BM_Extreme_Cases(benchmark::State& state) { } } BENCHMARK(BM_Extreme_Cases) -> Complexity(benchmark::O_N_log_N); -BENCHMARK(BM_Extreme_Cases)->Arg(42) -> Complexity(benchmark::O_Auto); +BENCHMARK(BM_Extreme_Cases) -> Arg(42) -> Complexity(benchmark::O_Auto); BENCHMARK_MAIN() \ No newline at end of file