From 37434f5baf632e839dc14b3c7d8745287cb9368a Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Tue, 25 Jul 2023 11:17:36 -0400 Subject: Benchmarks: mtree and vptree benchmark updates Note: cosine similarity doesn't seem to work for VPTree--I don't think that it is actually a metric, upon further research. At the very least I can't find anyone claiming it is, and I've found several people claiming it isn't. On testing with the Word2Vec data, Euclidean distance works insofar as the M-Tree and VPTree return the same KNN results for test queries, whereas Cosine Similarity does not work. --- benchmarks/include/bench.h | 3 ++- benchmarks/include/bench_utility.h | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'benchmarks/include') 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 -static bool query_latency_bench(DE &de_index, std::vector queries, size_t trial_cnt=100) { +static bool query_latency_bench(DE &de_index, std::vector 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 queries, size_t tr auto start = std::chrono::high_resolution_clock::now(); for (size_t j=0; j WRec; typedef de::Record Rec; const size_t W2V_SIZE = 300; -typedef de::CosinePoint Word2VecRec; +typedef de::EuclidPoint Word2VecRec; typedef de::DynamicExtension, de::WSSQuery> ExtendedWSS; typedef de::DynamicExtension, de::TrieSplineRangeQuery> 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 TreeMap; -typedef mt::mtree MTree; +typedef mt::mtree MTree; static gsl_rng *g_rng; static std::set *g_to_delete; -- cgit v1.2.3