From 37304a11b8edfef8fc627e7a3a095e77e70b07b1 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Tue, 13 Jun 2023 13:56:17 -0400 Subject: Benchmark refactoring --- benchmarks/include/bench.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 benchmarks/include/bench.h (limited to 'benchmarks/include/bench.h') diff --git a/benchmarks/include/bench.h b/benchmarks/include/bench.h new file mode 100644 index 0000000..d82da48 --- /dev/null +++ b/benchmarks/include/bench.h @@ -0,0 +1,67 @@ +#include "bench_utility.h" + +template +static bool insert_tput_bench(DE &de_index, std::fstream &file, size_t insert_cnt, + double delete_prop, std::vector &to_delete) { + + size_t delete_cnt = insert_cnt * delete_prop; + + size_t applied_deletes = 0; + size_t applied_inserts = 0; + + std::vector insert_vec; + std::vector delete_vec; + insert_vec.reserve(BATCH); + delete_vec.reserve(BATCH*delete_prop); + + size_t delete_idx = 0; + + bool continue_benchmark = true; + + size_t total_time = 0; + + while (applied_inserts < insert_cnt && continue_benchmark) { + continue_benchmark = build_insert_vec(file, insert_vec, BATCH, delete_prop, to_delete); + if (applied_deletes < delete_cnt) { + build_delete_vec(to_delete, delete_vec, BATCH*delete_prop); + delete_idx = 0; + } + + if (insert_vec.size() == 0) { + break; + } + + if constexpr (PROGRESS) { + progress_update((double) applied_inserts / (double) insert_cnt, "inserting:"); + } + + auto insert_start = std::chrono::high_resolution_clock::now(); + for (size_t i=0; i(insert_stop - insert_start).count(); + } + + if constexpr (PROGRESS) { + progress_update(1.0, "inserting:"); + } + + size_t throughput = (((double) (applied_inserts + applied_deletes) / (double) total_time) * 1e9); + + fprintf(stdout, "\n%ld\n", throughput); + reset_de_perf_metrics(); + + return continue_benchmark; +} + + -- cgit v1.2.3