summaryrefslogtreecommitdiffstats
path: root/benchmarks/include
diff options
context:
space:
mode:
Diffstat (limited to 'benchmarks/include')
-rw-r--r--benchmarks/include/bench.h3
-rw-r--r--benchmarks/include/bench_utility.h15
2 files changed, 15 insertions, 3 deletions
diff --git a/benchmarks/include/bench.h b/benchmarks/include/bench.h
index 12d0a7e..586ff12 100644
--- a/benchmarks/include/bench.h
+++ b/benchmarks/include/bench.h
@@ -85,7 +85,7 @@ static bool insert_tput_bench(DE &de_index, std::fstream &file, size_t insert_cn
}
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) {
+static bool query_latency_bench(DE &de_index, std::vector<QP> queries, size_t trial_cnt=1) {
char progbuf[25];
if constexpr (PROGRESS) {
sprintf(progbuf, "querying:");
@@ -102,6 +102,7 @@ static bool query_latency_bench(DE &de_index, std::vector<QP> queries, size_t tr
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();
diff --git a/benchmarks/include/bench_utility.h b/benchmarks/include/bench_utility.h
index 6610ab4..28040be 100644
--- a/benchmarks/include/bench_utility.h
+++ b/benchmarks/include/bench_utility.h
@@ -40,7 +40,7 @@ typedef de::WeightedRecord<key_type, value_type, weight_type> WRec;
typedef de::Record<key_type, value_type> Rec;
const size_t W2V_SIZE = 300;
-typedef de::CosinePoint<double, W2V_SIZE> Word2VecRec;
+typedef de::EuclidPoint<double, W2V_SIZE> Word2VecRec;
typedef de::DynamicExtension<WRec, de::WSS<WRec>, de::WSSQuery<WRec>> ExtendedWSS;
typedef de::DynamicExtension<Rec, de::TrieSpline<Rec>, de::TrieSplineRangeQuery<Rec>> ExtendedTSRQ;
@@ -68,6 +68,17 @@ struct btree_key_extract {
}
};
+struct euclidean_distance {
+ double operator()(const Word2VecRec &first, const Word2VecRec &second) const {
+ double dist = 0;
+ for (size_t i=0; i<W2V_SIZE; i++) {
+ dist += (first.data[i] - second.data[i]) * (first.data[i] - second.data[i]);
+ }
+
+ return std::sqrt(dist);
+ }
+};
+
struct cosine_similarity {
double operator()(const Word2VecRec &first, const Word2VecRec &second) const {
@@ -86,7 +97,7 @@ struct cosine_similarity {
};
typedef tlx::BTree<key_type, btree_record, btree_key_extract> TreeMap;
-typedef mt::mtree<Word2VecRec, cosine_similarity> MTree;
+typedef mt::mtree<Word2VecRec, euclidean_distance> MTree;
static gsl_rng *g_rng;
static std::set<WRec> *g_to_delete;