summaryrefslogtreecommitdiffstats
path: root/benchmarks/include/bench_utility.h
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2023-06-13 14:48:03 -0400
committerDouglas Rumbaugh <dbr4@psu.edu>2023-06-13 14:48:03 -0400
commit0e8d1ef77ad8db2b2491ae92874eb21b7986d59b (patch)
treede9d2edf558b68b09506b0d75a1ac7aa31adb8c4 /benchmarks/include/bench_utility.h
parent7559704587aa2c77ad4193bd54ec41412a14bb4b (diff)
downloaddynamic-extension-0e8d1ef77ad8db2b2491ae92874eb21b7986d59b.tar.gz
Benchmark refactoring/cleanup
Diffstat (limited to 'benchmarks/include/bench_utility.h')
-rw-r--r--benchmarks/include/bench_utility.h47
1 files changed, 36 insertions, 11 deletions
diff --git a/benchmarks/include/bench_utility.h b/benchmarks/include/bench_utility.h
index 78d6415..f208487 100644
--- a/benchmarks/include/bench_utility.h
+++ b/benchmarks/include/bench_utility.h
@@ -1,5 +1,13 @@
-#ifndef H_BENCH
-#define H_BENCH
+/*
+ * benchmarks/include/bench_utility.h
+ *
+ * Copyright (C) 2023 Douglas Rumbaugh <drumbaugh@psu.edu>
+ *
+ * All rights reserved. Published under the Modified BSD License.
+ *
+ */
+#pragma once
+
#include "framework/DynamicExtension.h"
#include "shard/WSS.h"
#include "shard/MemISAM.h"
@@ -29,7 +37,7 @@ typedef de::WeightedRecord<key_type, value_type, weight_type> WRec;
typedef de::Record<key_type, value_type> Rec;
typedef de::DynamicExtension<WRec, de::WSS<WRec>, de::WSSQuery<WRec>> ExtendedWSS;
-typedef de::DynamicExtension<Rec, de::TrieSpline<Rec>, de::TrieSplineRangeQuery<Rec>> ExtendedTS;
+typedef de::DynamicExtension<Rec, de::TrieSpline<Rec>, de::TrieSplineRangeQuery<Rec>> ExtendedTSRQ;
typedef de::DynamicExtension<Rec, de::PGM<Rec>, de::PGMRangeQuery<Rec>> ExtendedPGM;
static gsl_rng *g_rng;
@@ -82,6 +90,31 @@ static void delete_bench_env()
delete g_to_delete;
}
+/*
+ * NOTE: The QP type must have lower_bound and upper_bound attributes, which
+ * this function will initialize. Any other query parameter attributes must
+ * be manually initialized after the call.
+ */
+template <typename QP>
+static std::vector<QP> read_range_queries(std::string fname, double selectivity) {
+ std::vector<QP> queries;
+
+ FILE *qf = fopen(fname.c_str(), "r");
+ size_t start, stop;
+ double sel;
+ while (fscanf(qf, "%zu%zu%lf\n", &start, &stop, &sel) != EOF) {
+ if (start < stop && std::abs(sel - selectivity) < 0.1) {
+ QP q;
+ q.lower_bound = start;
+ q.upper_bound = stop;
+ queries.push_back(q);
+ }
+ }
+ fclose(qf);
+
+ return queries;
+}
+
template <de::RecordInterface R>
static bool next_record(std::fstream &file, R &record)
{
@@ -213,12 +246,6 @@ static bool warmup(std::fstream &file, DE &extended_index, size_t count,
}
}
- /*
- if (progress) {
- progress_update(1, "warming up:");
- }
- */
-
return true;
}
@@ -232,5 +259,3 @@ static void reset_de_perf_metrics() {
RESET_IO_CNT();
}
-
-#endif // H_BENCH