Skip to content

Commit

Permalink
feat: iteration benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelkallis committed May 8, 2021
1 parent a15cfd4 commit 89f0441
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
54 changes: 54 additions & 0 deletions bench/query_iteration.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* @file query iteration microbenchmarks
* @author Rafael Kallis <rk@rafaelkallis.com>
*/

#include "art.hpp"
#include "picobench/picobench.hpp"
#include "zipf.hpp"
#include <functional>
#include <map>
#include <string>
#include <unordered_map>

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<int> m;
hash<uint32_t> h;
int v = 1;
int *v_ptr = &v;
art::tree_it<int> 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<int> m;
hash<uint32_t> h;
int v = 1;
int *v_ptr = &v;
art::tree_it<int> 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});

0 comments on commit 89f0441

Please sign in to comment.