From ac3ec2ded37e4f9e4083f8b65644f7c4b60336d7 Mon Sep 17 00:00:00 2001 From: Ismael Date: Thu, 26 May 2016 21:16:40 +0200 Subject: [PATCH] moved complexity.h into src and BigO enum into benchmark_api --- include/benchmark/benchmark_api.h | 15 ++++++++++++++- src/complexity.cc | 2 +- {include/benchmark => src}/complexity.h | 22 +++++----------------- src/console_reporter.cc | 2 +- src/reporter.cc | 2 +- 5 files changed, 22 insertions(+), 21 deletions(-) rename {include/benchmark => src}/complexity.h (81%) diff --git a/include/benchmark/benchmark_api.h b/include/benchmark/benchmark_api.h index 9c32bace..29d0f6bb 100644 --- a/include/benchmark/benchmark_api.h +++ b/include/benchmark/benchmark_api.h @@ -154,7 +154,6 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond); #include #include "macros.h" -#include "complexity.h" namespace benchmark { class BenchmarkReporter; @@ -239,6 +238,20 @@ enum TimeUnit { kMillisecond }; +// BigO is passed to a benchmark in order to specify the asymptotic computational +// complexity for the benchmark. In case oAuto is selected, complexity will be +// calculated automatically to the best fit. +enum BigO { + oNone, + o1, + oN, + oNSquared, + oNCubed, + oLogN, + oNLogN, + oAuto +}; + // State is passed to a running Benchmark and contains state for the // benchmark to use. class State { diff --git a/src/complexity.cc b/src/complexity.cc index e7233109..c3dd40e8 100644 --- a/src/complexity.cc +++ b/src/complexity.cc @@ -15,7 +15,7 @@ // Source project : https://github.com/ismaelJimenez/cpp.leastsq // Adapted to be used with google benchmark -#include "benchmark/complexity.h" +#include "complexity.h" #include "check.h" #include #include diff --git a/include/benchmark/complexity.h b/src/complexity.h similarity index 81% rename from include/benchmark/complexity.h rename to src/complexity.h index 76318d8b..9b1ae8dc 100644 --- a/include/benchmark/complexity.h +++ b/src/complexity.h @@ -21,21 +21,9 @@ #include #include -namespace benchmark { +#include "benchmark/benchmark_api.h" -// BigO is passed to a benchmark in order to specify the asymptotic computational -// complexity for the benchmark. In case oAuto is selected, complexity will be -// calculated automatically to the best fit. -enum BigO { - oNone, - o1, - oN, - oNSquared, - oNCubed, - oLogN, - oNLogN, - oAuto -}; +namespace benchmark { // This data structure will contain the result returned by MinimalLeastSq // - coef : Estimated coeficient for the high-order term as @@ -54,17 +42,17 @@ struct LeastSq { double coef; double rms; - BigO complexity; + benchmark::BigO complexity; }; // Function to return an string for the calculated complexity -std::string GetBigOString(BigO complexity); +std::string GetBigOString(benchmark::BigO complexity); // Find the coefficient for the high-order term in the running time, by // minimizing the sum of squares of relative error. LeastSq MinimalLeastSq(const std::vector& n, const std::vector& time, - const BigO complexity = oAuto); + const benchmark::BigO complexity = oAuto); } // end namespace benchmark #endif // COMPLEXITY_H_ diff --git a/src/console_reporter.cc b/src/console_reporter.cc index bd5b403f..62df4c7f 100644 --- a/src/console_reporter.cc +++ b/src/console_reporter.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "benchmark/reporter.h" -#include "benchmark/complexity.h" +#include "complexity.h" #include #include diff --git a/src/reporter.cc b/src/reporter.cc index 9b65c9ba..aa1e69af 100644 --- a/src/reporter.cc +++ b/src/reporter.cc @@ -13,7 +13,7 @@ // limitations under the License. #include "benchmark/reporter.h" -#include "benchmark/complexity.h" +#include "complexity.h" #include #include