diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-07-02 05:30:54 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-07-02 05:30:54 +0000 |
commit | c835c12f6c4e6ca1b721f45ae27bf2385f0cf48a (patch) | |
tree | 4d2a4455b7f6d619c938fb6bce785d792b39cec0 /libcxx | |
parent | f977598bb629afeb3f7cf591bd483f21adfab1a7 (diff) | |
download | llvm-c835c12f6c4e6ca1b721f45ae27bf2385f0cf48a.zip llvm-c835c12f6c4e6ca1b721f45ae27bf2385f0cf48a.tar.gz llvm-c835c12f6c4e6ca1b721f45ae27bf2385f0cf48a.tar.bz2 |
Add unordered_map::insert benchmark test and rename file
llvm-svn: 274424
Diffstat (limited to 'libcxx')
-rw-r--r-- | libcxx/benchmarks/set_find.pass.cpp | 29 | ||||
-rw-r--r-- | libcxx/benchmarks/unordered_set_operations.bench.cpp | 44 |
2 files changed, 44 insertions, 29 deletions
diff --git a/libcxx/benchmarks/set_find.pass.cpp b/libcxx/benchmarks/set_find.pass.cpp deleted file mode 100644 index 32f9026..0000000 --- a/libcxx/benchmarks/set_find.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include <unordered_set> -#include <vector> -#include <cstdint> - -#include "benchmark/benchmark_api.h" - -template <class IntT> -std::vector<IntT> getInputs(size_t N) { - std::vector<IntT> inputs; - for (size_t i=0; i < N; ++i) { - inputs.push_back(i); - } - return inputs; -} - -template <class Container, class Inputs> -void BM_SetLookup(benchmark::State& st, Container c, Inputs const& in) { - c.insert(in.begin(), in.end()); - const auto end = in.end(); - while (st.KeepRunning()) { - for (auto it = in.begin(); it != end; ++it) { - benchmark::DoNotOptimize(c.find(*it++)); - } - } -} -BENCHMARK_CAPTURE(BM_SetLookup, uint32_lookup, - std::unordered_set<uint32_t>{}, getInputs<uint32_t>(1024)); - -BENCHMARK_MAIN() diff --git a/libcxx/benchmarks/unordered_set_operations.bench.cpp b/libcxx/benchmarks/unordered_set_operations.bench.cpp new file mode 100644 index 0000000..c9ee689 --- /dev/null +++ b/libcxx/benchmarks/unordered_set_operations.bench.cpp @@ -0,0 +1,44 @@ +#include <unordered_set> +#include <vector> +#include <cstdint> + +#include "benchmark/benchmark_api.h" + +template <class IntT> +std::vector<IntT> getInputs(size_t N) { + std::vector<IntT> inputs; + for (size_t i=0; i < N; ++i) { + inputs.push_back(i); + } + return inputs; +} + +template <class Container, class Inputs> +void BM_SetInsert(benchmark::State& st, Container c, Inputs const& in) { + const auto end = in.end(); + while (st.KeepRunning()) { + c.clear(); + for (auto it = in.begin(); it != end; ++it) { + benchmark::DoNotOptimize(c.insert(*it)); + } + benchmark::DoNotOptimize(c); + } +} +BENCHMARK_CAPTURE(BM_SetInsert, uint32_insert, + std::unordered_set<uint32_t>{}, getInputs<uint32_t>(1024)); + +template <class Container, class Inputs> +void BM_SetFind(benchmark::State& st, Container c, Inputs const& in) { + c.insert(in.begin(), in.end()); + const auto end = in.end(); + while (st.KeepRunning()) { + for (auto it = in.begin(); it != end; ++it) { + benchmark::DoNotOptimize(c.find(*it)); + } + } +} +BENCHMARK_CAPTURE(BM_SetFind, uint32_lookup, + std::unordered_set<uint32_t>{}, getInputs<uint32_t>(1024)); + + +BENCHMARK_MAIN() |