diff options
author | Eric Fiselier <eric@efcs.ca> | 2018-07-10 04:02:00 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2018-07-10 04:02:00 +0000 |
commit | fcafd3e6002cb682d737ddf56f1d972358dbfa61 (patch) | |
tree | a1cd9d15d739472558d8c4a325c5b492410d8f51 /libcxx/utils/google-benchmark/test/complexity_test.cc | |
parent | 1c5ae9bc1f557fb27471c20de9fb3697de7f365e (diff) | |
download | bcm5719-llvm-fcafd3e6002cb682d737ddf56f1d972358dbfa61.tar.gz bcm5719-llvm-fcafd3e6002cb682d737ddf56f1d972358dbfa61.zip |
Update google-benchark to trunk
llvm-svn: 336635
Diffstat (limited to 'libcxx/utils/google-benchmark/test/complexity_test.cc')
-rw-r--r-- | libcxx/utils/google-benchmark/test/complexity_test.cc | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/libcxx/utils/google-benchmark/test/complexity_test.cc b/libcxx/utils/google-benchmark/test/complexity_test.cc index 89dfa580e6b..5f91660898b 100644 --- a/libcxx/utils/google-benchmark/test/complexity_test.cc +++ b/libcxx/utils/google-benchmark/test/complexity_test.cc @@ -55,7 +55,7 @@ void BM_Complexity_O1(benchmark::State& state) { } BENCHMARK(BM_Complexity_O1)->Range(1, 1 << 18)->Complexity(benchmark::o1); BENCHMARK(BM_Complexity_O1)->Range(1, 1 << 18)->Complexity(); -BENCHMARK(BM_Complexity_O1)->Range(1, 1 << 18)->Complexity([](int) { +BENCHMARK(BM_Complexity_O1)->Range(1, 1 << 18)->Complexity([](int64_t) { return 1.0; }); @@ -81,19 +81,19 @@ ADD_COMPLEXITY_CASES(big_o_1_test_name, rms_o_1_test_name, lambda_big_o_1); // --------------------------- Testing BigO O(N) --------------------------- // // ========================================================================= // -std::vector<int> ConstructRandomVector(int size) { +std::vector<int> ConstructRandomVector(int64_t size) { std::vector<int> v; - v.reserve(size); + v.reserve(static_cast<int>(size)); for (int i = 0; i < size; ++i) { - v.push_back(std::rand() % size); + v.push_back(static_cast<int>(std::rand() % size)); } return v; } void BM_Complexity_O_N(benchmark::State& state) { auto v = ConstructRandomVector(state.range(0)); - const int item_not_in_vector = - state.range(0) * 2; // Test worst case scenario (item not in vector) + // Test worst case scenario (item not in vector) + const int64_t item_not_in_vector = state.range(0) * 2; for (auto _ : state) { benchmark::DoNotOptimize(std::find(v.begin(), v.end(), item_not_in_vector)); } @@ -106,7 +106,7 @@ BENCHMARK(BM_Complexity_O_N) BENCHMARK(BM_Complexity_O_N) ->RangeMultiplier(2) ->Range(1 << 10, 1 << 16) - ->Complexity([](int n) -> double { return n; }); + ->Complexity([](int64_t n) -> double { return static_cast<double>(n); }); BENCHMARK(BM_Complexity_O_N) ->RangeMultiplier(2) ->Range(1 << 10, 1 << 16) @@ -134,6 +134,7 @@ static void BM_Complexity_O_N_log_N(benchmark::State& state) { } state.SetComplexityN(state.range(0)); } +static const double kLog2E = 1.44269504088896340736; BENCHMARK(BM_Complexity_O_N_log_N) ->RangeMultiplier(2) ->Range(1 << 10, 1 << 16) @@ -141,7 +142,7 @@ BENCHMARK(BM_Complexity_O_N_log_N) BENCHMARK(BM_Complexity_O_N_log_N) ->RangeMultiplier(2) ->Range(1 << 10, 1 << 16) - ->Complexity([](int n) { return n * log2(n); }); + ->Complexity([](int64_t n) { return kLog2E * n * log(static_cast<double>(n)); }); BENCHMARK(BM_Complexity_O_N_log_N) ->RangeMultiplier(2) ->Range(1 << 10, 1 << 16) |