From 89f04418c05b8fe81841bad90ac583afadfda45b Mon Sep 17 00:00:00 2001 From: Rafael Kallis Date: Sat, 8 May 2021 10:34:27 +0200 Subject: [PATCH] feat: iteration benchmarks --- CMakeLists.txt | 1 + bench/query_iteration.cpp | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 bench/query_iteration.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d2653f2..330dcc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,7 @@ add_executable(bench # "${PROJECT_SOURCE_DIR}/bench/node_16.cpp" # "${PROJECT_SOURCE_DIR}/bench/node_48.cpp" # "${PROJECT_SOURCE_DIR}/bench/node_256.cpp" + # "${PROJECT_SOURCE_DIR}/bench/query_iteration.cpp" "${PROJECT_SOURCE_DIR}/bench/query_sparse_uniform.cpp" "${PROJECT_SOURCE_DIR}/bench/query_sparse_uniform_64.cpp" "${PROJECT_SOURCE_DIR}/bench/query_sparse_zipf.cpp" diff --git a/bench/query_iteration.cpp b/bench/query_iteration.cpp new file mode 100644 index 0000000..f20fb7f --- /dev/null +++ b/bench/query_iteration.cpp @@ -0,0 +1,54 @@ +/** + * @file query iteration microbenchmarks + * @author Rafael Kallis + */ + +#include "art.hpp" +#include "picobench/picobench.hpp" +#include "zipf.hpp" +#include +#include +#include +#include + +using picobench::state; +using std::string; +using std::to_string; +using std::hash; +using std::mt19937_64; +using std::map; +using std::unordered_map; + +PICOBENCH_SUITE("query iteration"); + +static void full_scan_zipf(state &s) { + art::art m; + hash h; + int v = 1; + int *v_ptr = &v; + art::tree_it it, it_end; + fast_zipf rng(1000000); + for (int i = 0; i < 100000; ++i) { + m.set(to_string(h(rng())).c_str(), v_ptr); + } + for (auto i __attribute__((unused)) : s) { + for (it = m.begin(), it_end = m.end(); it != it_end; ++it) {} + } +} +PICOBENCH(full_scan_zipf).iterations({1000}); + +static void full_scan_uniform(state &s) { + art::art m; + hash h; + int v = 1; + int *v_ptr = &v; + art::tree_it it, it_end; + mt19937_64 rng(0); + for (int i = 0; i < 100000; ++i) { + m.set(to_string(h(rng())).c_str(), v_ptr); + } + for (auto i __attribute__((unused)) : s) { + for (it = m.begin(), it_end = m.end(); it != it_end; ++it) {} + } +} +PICOBENCH(full_scan_uniform).iterations({1000}); \ No newline at end of file