diff options
| author | Douglas Rumbaugh <dbr4@psu.edu> | 2023-06-13 14:48:03 -0400 |
|---|---|---|
| committer | Douglas Rumbaugh <dbr4@psu.edu> | 2023-06-13 14:48:03 -0400 |
| commit | 0e8d1ef77ad8db2b2491ae92874eb21b7986d59b (patch) | |
| tree | de9d2edf558b68b09506b0d75a1ac7aa31adb8c4 /benchmarks/include/bench.h | |
| parent | 7559704587aa2c77ad4193bd54ec41412a14bb4b (diff) | |
| download | dynamic-extension-0e8d1ef77ad8db2b2491ae92874eb21b7986d59b.tar.gz | |
Benchmark refactoring/cleanup
Diffstat (limited to 'benchmarks/include/bench.h')
| -rw-r--r-- | benchmarks/include/bench.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/benchmarks/include/bench.h b/benchmarks/include/bench.h index d82da48..6a9c263 100644 --- a/benchmarks/include/bench.h +++ b/benchmarks/include/bench.h @@ -1,3 +1,13 @@ +/* + * benchmarks/include/bench.h + * + * Copyright (C) 2023 Douglas Rumbaugh <drumbaugh@psu.edu> + * + * All rights reserved. Published under the Modified BSD License. + * + */ +#pragma once + #include "bench_utility.h" template <typename DE, de::RecordInterface R, bool PROGRESS=true, size_t BATCH=1000> @@ -64,4 +74,37 @@ static bool insert_tput_bench(DE &de_index, std::fstream &file, size_t insert_cn return continue_benchmark; } +template <typename DE, de::RecordInterface R, typename QP, bool PROGRESS=true> +static bool query_latency_bench(DE &de_index, 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); + } + + auto start = std::chrono::high_resolution_clock::now(); + for (size_t j=0; j<queries.size(); j++) { + auto res = de_index.query(&queries[j]); + total_results += res.size(); + } + 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; +} |