summaryrefslogtreecommitdiffstats
path: root/benchmarks/include
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2023-06-26 10:09:46 -0400
committerDouglas Rumbaugh <dbr4@psu.edu>2023-06-26 10:09:46 -0400
commit9864552a3f2b533c47076a7f6efe246e77deb440 (patch)
treefe048914cae002e88a21fb20ea1c1897d4662b92 /benchmarks/include
parent05642ae192f50e7a40dc198451545f03f6b4d79a (diff)
downloaddynamic-extension-9864552a3f2b533c47076a7f6efe246e77deb440.tar.gz
Added static benchmarking
Diffstat (limited to 'benchmarks/include')
-rw-r--r--benchmarks/include/bench.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/benchmarks/include/bench.h b/benchmarks/include/bench.h
index 6a9c263..db8fc77 100644
--- a/benchmarks/include/bench.h
+++ b/benchmarks/include/bench.h
@@ -108,3 +108,44 @@ static bool query_latency_bench(DE &de_index, std::vector<QP> queries, size_t tr
return true;
}
+
+
+template <typename Shard, de::RecordInterface R, typename QP, QueryInterface Q, bool PROGRESS=true>
+static bool static_latency_bench(Shard *shard, std::vector<QP> queries, size_t trial_cnt=100) {
+ char progbuf[25];
+ if constexpr (PROGRESS) {
+ sprintf(progbuf, "querying:");
+ }
+
+ size_t total_time = 0;
+ size_t total_results = 0;
+
+ for (size_t i=0; i<trial_cnt; i++) {
+ if constexpr (PROGRESS) {
+ progress_update((double) (i) / (double) trial_cnt, progbuf);
+ }
+
+ std::vector<void *> states(1);
+
+ auto start = std::chrono::high_resolution_clock::now();
+ for (size_t j=0; j<queries.size(); j++) {
+ states[0] = Q::get_query_state(shard, &queries[i]);
+ Q::process_query_states(shard, states, nullptr);
+ auto res = Q::query(shard, states[0], &queries[i]);
+ total_results += res.size();
+ Q::delete_query_state(states[0]);
+ }
+ auto stop = std::chrono::high_resolution_clock::now();
+
+ total_time += std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
+ }
+
+ progress_update(1.0, progbuf);
+
+ size_t query_latency = total_time / (trial_cnt * queries.size());
+
+ fprintf(stdout, "%ld\t", query_latency);
+ fflush(stdout);
+
+ return true;
+}