changed BigOFunc argument from size_t to int

This commit is contained in:
Ismael 2016-06-02 22:21:52 +02:00
parent f964480080
commit 240ba4e64e
4 changed files with 11 additions and 11 deletions

View File

@ -147,7 +147,7 @@ that might be used to customize high-order term calculation.
```c++ ```c++
BENCHMARK(BM_StringCompare)->RangeMultiplier(2) BENCHMARK(BM_StringCompare)->RangeMultiplier(2)
->Range(1<<10, 1<<18)->Complexity([](size_t n)->double{return n; }); ->Range(1<<10, 1<<18)->Complexity([](int n)->double{return n; });
``` ```
### Templated benchmarks ### Templated benchmarks

View File

@ -253,7 +253,7 @@ enum BigO {
// BigOFunc is passed to a benchmark in order to specify the asymptotic // BigOFunc is passed to a benchmark in order to specify the asymptotic
// computational complexity for the benchmark. // computational complexity for the benchmark.
typedef double(BigOFunc)(size_t); typedef double(BigOFunc)(int);
// State is passed to a running Benchmark and contains state for the // State is passed to a running Benchmark and contains state for the
// benchmark to use. // benchmark to use.

View File

@ -29,18 +29,18 @@ namespace benchmark {
BigOFunc* FittingCurve(BigO complexity) { BigOFunc* FittingCurve(BigO complexity) {
switch (complexity) { switch (complexity) {
case oN: case oN:
return [](size_t n) -> double { return n; }; return [](int n) -> double { return n; };
case oNSquared: case oNSquared:
return [](size_t n) -> double { return n * n; }; return [](int n) -> double { return n * n; };
case oNCubed: case oNCubed:
return [](size_t n) -> double { return n * n * n; }; return [](int n) -> double { return n * n * n; };
case oLogN: case oLogN:
return [](size_t n) { return log2(n); }; return [](int n) { return log2(n); };
case oNLogN: case oNLogN:
return [](size_t n) { return n * log2(n); }; return [](int n) { return n * log2(n); };
case o1: case o1:
default: default:
return [](size_t) { return 1.0; }; return [](int) { return 1.0; };
} }
} }

View File

@ -154,7 +154,7 @@ void BM_Complexity_O1(benchmark::State& state) {
state.SetComplexityN(state.range_x()); state.SetComplexityN(state.range_x());
} }
BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity(benchmark::o1); BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity(benchmark::o1);
BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity([](size_t){return 1.0; }); BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity([](int){return 1.0; });
BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity(); BENCHMARK(BM_Complexity_O1) -> Range(1, 1<<18) -> Complexity();
std::string big_o_1_test_name = "BM_Complexity_O1_BigO"; std::string big_o_1_test_name = "BM_Complexity_O1_BigO";
@ -192,7 +192,7 @@ void BM_Complexity_O_N(benchmark::State& state) {
state.SetComplexityN(state.range_x()); state.SetComplexityN(state.range_x());
} }
BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::oN); BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::oN);
BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity([](size_t n) -> double{return n; }); BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity([](int n) -> double{return n; });
BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(); BENCHMARK(BM_Complexity_O_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity();
std::string big_o_n_test_name = "BM_Complexity_O_N_BigO"; std::string big_o_n_test_name = "BM_Complexity_O_N_BigO";
@ -220,7 +220,7 @@ static void BM_Complexity_O_N_log_N(benchmark::State& state) {
state.SetComplexityN(state.range_x()); state.SetComplexityN(state.range_x());
} }
BENCHMARK(BM_Complexity_O_N_log_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::oNLogN); BENCHMARK(BM_Complexity_O_N_log_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(benchmark::oNLogN);
BENCHMARK(BM_Complexity_O_N_log_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity([](size_t n) {return n * log2(n); }); BENCHMARK(BM_Complexity_O_N_log_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity([](int n) {return n * log2(n); });
BENCHMARK(BM_Complexity_O_N_log_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity(); BENCHMARK(BM_Complexity_O_N_log_N) -> RangeMultiplier(2) -> Range(1<<10, 1<<16) -> Complexity();
std::string big_o_n_lg_n_test_name = "BM_Complexity_O_N_log_N_BigO"; std::string big_o_n_lg_n_test_name = "BM_Complexity_O_N_log_N_BigO";