forked from organicmaps/organicmaps
[search] Added a timer and some additional information to the output of the quality tests.
This commit is contained in:
parent
e423bc79fe
commit
ae508dcad5
2 changed files with 44 additions and 5 deletions
|
@ -30,3 +30,7 @@ tehama 4th street
|
|||
чехов улица чехова
|
||||
депутатский
|
||||
6 route des jeunes Genève
|
||||
москва 4 2 останкинская
|
||||
улица Константина Симонова
|
||||
фрезерная 1, д. 2/1, стр. 1
|
||||
фрезерная 1, д. 2/1, стр. 10
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "search/params.hpp"
|
||||
|
||||
#include "indexer/classificator_loader.hpp"
|
||||
#include "indexer/data_header.hpp"
|
||||
#include "indexer/index.hpp"
|
||||
#include "indexer/mwm_set.hpp"
|
||||
|
||||
|
@ -17,10 +18,13 @@
|
|||
#include "platform/platform.hpp"
|
||||
|
||||
#include "coding/file_name_utils.hpp"
|
||||
#include "coding/reader_wrapper.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/scope_guard.hpp"
|
||||
#include "base/timer.hpp"
|
||||
|
||||
#include "std/cstdio.hpp"
|
||||
#include "std/fstream.hpp"
|
||||
#include "std/iostream.hpp"
|
||||
#include "std/numeric.hpp"
|
||||
|
@ -41,6 +45,10 @@ DEFINE_int32(top, 1, "Number of top results to show for every query");
|
|||
string const kDefaultQueriesPathSuffix = "/../search/search_quality_tests/queries.txt";
|
||||
string const kEmptyResult = "<empty>";
|
||||
|
||||
m2::RectD const kDefaultViewport(m2::PointD(0.0, 0.0), m2::PointD(1.0, 1.0));
|
||||
m2::RectD const kMoscowViewport =
|
||||
MercatorBounds::RectByCenterXYAndSizeInMeters(m2::PointD(37.6531, 55.7516), 5000);
|
||||
|
||||
class SearchQueryV2Factory : public search::SearchQueryFactory
|
||||
{
|
||||
// search::SearchQueryFactory overrides:
|
||||
|
@ -69,9 +77,14 @@ void ReadStringsFromFile(string const & path, vector<string> & result)
|
|||
// If n == 1, prints the query and the top result separated by a tab.
|
||||
// Otherwise, prints the query on a separate line
|
||||
// and then prints n top results on n lines starting with tabs.
|
||||
void PrintTopResults(string const & query, vector<search::Result> const & results, size_t n)
|
||||
void PrintTopResults(string const & query, vector<search::Result> const & results, size_t n,
|
||||
double elapsedSeconds)
|
||||
{
|
||||
cout << query;
|
||||
char timeBuf[100];
|
||||
sprintf(timeBuf, "\t[%.3fs]", elapsedSeconds);
|
||||
if (n > 1)
|
||||
cout << timeBuf;
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
{
|
||||
if (n > 1)
|
||||
|
@ -83,9 +96,24 @@ void PrintTopResults(string const & query, vector<search::Result> const & result
|
|||
else
|
||||
cout << kEmptyResult;
|
||||
}
|
||||
if (n == 1)
|
||||
cout << timeBuf;
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
uint64_t ReadVersionFromHeader(platform::LocalCountryFile const & mwm)
|
||||
{
|
||||
if (mwm.GetCountryName() == "World" || mwm.GetCountryName() == "WorldCoasts")
|
||||
return mwm.GetVersion();
|
||||
|
||||
ModelReaderPtr reader = FilesContainerR(mwm.GetPath(MapOptions::Map)).GetReader(VERSION_FILE_TAG);
|
||||
ReaderSrc src(reader.GetPtr());
|
||||
|
||||
version::MwmVersion version;
|
||||
version::ReadVersion(src, version);
|
||||
return version.timestamp;
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
ios_base::sync_with_stdio(false);
|
||||
|
@ -122,11 +150,18 @@ int main(int argc, char * argv[])
|
|||
for (auto & map : mwms)
|
||||
map.SyncWithDisk();
|
||||
}
|
||||
for (auto const & mwm : mwms)
|
||||
cout << "Mwms used in all search invocations:" << endl;
|
||||
for (auto & mwm : mwms)
|
||||
{
|
||||
LOG(LINFO, ("Registering map:", mwm.GetCountryName()));
|
||||
mwm.SyncWithDisk();
|
||||
cout << mwm.GetCountryName() << " " << ReadVersionFromHeader(mwm) << endl;
|
||||
engine.RegisterMap(mwm);
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
// auto const & viewport = kDefaultViewport;
|
||||
auto const & viewport = kMoscowViewport;
|
||||
cout << "Viewport used in all search invocations: " << DebugPrint(viewport) << endl << endl;
|
||||
|
||||
vector<string> queries;
|
||||
string queriesPath = FLAGS_queries_path;
|
||||
|
@ -136,12 +171,12 @@ int main(int argc, char * argv[])
|
|||
|
||||
for (string const & query : queries)
|
||||
{
|
||||
my::Timer timer;
|
||||
// todo(@m) Viewport and position should belong to the query info.
|
||||
m2::RectD viewport(m2::PointD(0.0, 0.0), m2::PointD(1.0, 1.0));
|
||||
TestSearchRequest request(engine, query, FLAGS_locale, search::SearchParams::ALL, viewport);
|
||||
request.Wait();
|
||||
|
||||
PrintTopResults(query, request.Results(), FLAGS_top);
|
||||
PrintTopResults(query, request.Results(), FLAGS_top, timer.ElapsedSeconds());
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue