From 9f0483c7305d86ccc66d3409c5b0d250961db305 Mon Sep 17 00:00:00 2001 From: Maxim Pimenov Date: Mon, 18 Nov 2019 15:16:06 +0300 Subject: [PATCH] [search] Logging batch timings in Emitter. --- search/emitter.hpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/search/emitter.hpp b/search/emitter.hpp index e20e5c15f0..d68eccb8c3 100644 --- a/search/emitter.hpp +++ b/search/emitter.hpp @@ -4,6 +4,7 @@ #include "search/search_params.hpp" #include "base/logging.hpp" +#include "base/timer.hpp" #include @@ -22,6 +23,7 @@ public: m_onResults = onResults; m_results.Clear(); m_prevEmitSize = 0; + m_timer.Reset(); } bool AddResult(Result && res) { return m_results.AddResult(std::move(res)); } @@ -29,12 +31,15 @@ public: void AddBookmarkResult(bookmarks::Result const & result) { m_results.AddBookmarkResult(result); } - void Emit() + void Emit(bool force = false) { - if (m_prevEmitSize == m_results.GetCount()) + if (m_prevEmitSize == m_results.GetCount() && !force) return; m_prevEmitSize = m_results.GetCount(); + LOG(LINFO, ("Emitting a new batch of results. Time since search start:", + m_timer.ElapsedSeconds(), "seconds.")); + if (m_onResults) m_onResults(m_results); else @@ -46,15 +51,13 @@ public: void Finish(bool cancelled) { m_results.SetEndMarker(cancelled); - if (m_onResults) - m_onResults(m_results); - else - LOG(LERROR, ("OnResults is not set.")); + Emit(true /* force */); } private: SearchParams::OnResults m_onResults; Results m_results; size_t m_prevEmitSize = 0; + base::Timer m_timer; }; } // namespace search