diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2023-12-13 12:40:16 -0500 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2023-12-13 12:40:16 -0500 |
| commit | 2f5bab07e5f151f26ef07478a4f251feaeeb0d26 (patch) | |
| tree | 08f29895abd1cfb32e899f2e6cb12290e930007f /benchmarks | |
| parent | 3c127eda69295cb306739bdd3c5ddccff6026a8d (diff) | |
| download | dynamic-extension-2f5bab07e5f151f26ef07478a4f251feaeeb0d26.tar.gz | |
Query throughput benchmark
Diffstat (limited to 'benchmarks')
| -rw-r--r-- | benchmarks/insert_query_tput.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/benchmarks/insert_query_tput.cpp b/benchmarks/insert_query_tput.cpp new file mode 100644 index 0000000..fe85e68 --- /dev/null +++ b/benchmarks/insert_query_tput.cpp @@ -0,0 +1,79 @@ +/* + * + */ + +#define ENABLE_TIMER + +#include <thread> + +#include "framework/DynamicExtension.h" +#include "shard/ISAMTree.h" +#include "query/rangequery.h" +#include "framework/interface/Record.h" + +#include "psu-util/timer.h" + + +typedef de::Record<int64_t, int64_t> Rec; +typedef de::ISAMTree<Rec> ISAM; +typedef de::rq::Query<ISAM, Rec> Q; +typedef de::DynamicExtension<Rec, ISAM, Q> Ext; + +std::atomic<bool> inserts_done = false; + +void insert_thread(Ext *extension, size_t n, size_t k) { + TIMER_INIT(); + for (int64_t i=0; i<n; i+=k) { + TIMER_START(); + for (int64_t j=0; j<k; j++) { + Rec r = {i+j, i+j}; + extension->insert(r); + } + TIMER_STOP(); + auto insert_lat = TIMER_RESULT(); + + fprintf(stdout, "I\t%ld\t%ld\t%ld\n", extension->get_record_count(), insert_lat, k); + } + + inserts_done.store(true); +} + +void query_thread(Ext *extension, double selectivity, size_t k) { + TIMER_INIT(); + + while (!inserts_done.load()) { + size_t reccnt = extension->get_record_count(); + size_t range = reccnt * selectivity; + + auto q = new de::rq::Parms<Rec>(); + + TIMER_START(); + for (int64_t i=0; i<k; i++) { + size_t start = rand() % (reccnt - range); + q->lower_bound = start; + q->upper_bound = start + range; + auto res = extension->query(q); + auto r = res.get(); + } + TIMER_STOP(); + auto query_lat = TIMER_RESULT(); + fprintf(stdout, "Q\t%ld\t%ld\t%ld\n", reccnt, query_lat, k); + } +} + +int main(int argc, char **argv) { + + /* the closeout routine takes _forever_ ... so we'll just leak the memory */ + auto extension = new Ext(10000, 2, 1, 0, 2); + size_t n = 10000000; + size_t per_trial = 1000; + double selectivity = .001; + + std::thread i_thrd(insert_thread, extension, n, per_trial); + std::thread q_thrd(query_thread, extension, selectivity, 1); + + q_thrd.join(); + i_thrd.join(); + fflush(stderr); +} + |