Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Log times for operations.

Kishore Nalland2798ac00b00
diff --git a/src/art.cpp b/src/art.cpp
index 40017d0c..311e1993 100644
--- a/src/art.cpp
+++ b/src/art.cpp
@@ -1024,6 +1024,8 @@ int art_topk_iter(const art_node *root, token_ordering token_order, size_t max_r
}
}
+ LOG(INFO) << "leaf results.size: " << results.size();
+
printf("OUTSIDE art_topk_iter: results size: %d\n", results.size());
return 0;
}
diff --git a/src/index.cpp b/src/index.cpp
index d77bf416..40580704 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -1212,7 +1212,7 @@ void Index::search_candidates(const uint8_t & field_id, bool field_is_array,
void Index::do_filtering(uint32_t*& filter_ids, uint32_t& filter_ids_length,
const std::vector<filter>& filters,
const bool enable_short_circuit) const {
- //auto begin = std::chrono::high_resolution_clock::now();
+ auto begin = std::chrono::high_resolution_clock::now();
for(size_t i = 0; i < filters.size(); i++) {
const filter & a_filter = filters[i];
@@ -1552,10 +1552,10 @@ void Index::do_filtering(uint32_t*& filter_ids, uint32_t& filter_ids_length,
}
}
- /*long long int timeMillis =
+ long long int timeMillis =
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - begin).count();
- LOG(INFO) << "Time taken for filtering: " << timeMillis << "ms";*/
+ LOG(INFO) << "Time taken for filtering: " << timeMillis << "ms";
}
@@ -2881,11 +2881,18 @@ void Index::search_field(const uint8_t & field_id,
// prefix should apply only for last token
const size_t token_len = prefix_search ? (int) token.length() : (int) token.length() + 1;
+ auto begin = std::chrono::high_resolution_clock::now();
+
// need less candidates for filtered searches since we already only pick tokens with results
art_fuzzy_search(search_index.at(field_name), (const unsigned char *) token.c_str(), token_len,
costs[token_index], costs[token_index], num_fuzzy_candidates, token_order, prefix_search,
filter_ids, filter_ids_length, leaves, unique_tokens);
+ auto timeMillis = std::chrono::duration_cast<std::chrono::milliseconds>(
+ std::chrono::high_resolution_clock::now() - begin).count();
+
+ LOG(INFO) << "Time taken for fuzzy search: " << timeMillis << "ms";
+
if(!leaves.empty()) {
token_cost_cache.emplace(token_cost_hash, leaves);
for(auto leaf: leaves) {