forked from organicmaps/organicmaps
[search] Logging batch timings in Emitter.
This commit is contained in:
parent
0af1c0ebfd
commit
9f0483c730
1 changed files with 9 additions and 6 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "search/search_params.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/timer.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue