Print mwm scales in benchmark_tool.

This commit is contained in:
vng 2011-10-17 16:06:54 +03:00 committed by Alex Zolotarev
parent 5561301959
commit 57b754ae45
5 changed files with 36 additions and 30 deletions

View file

@ -12,22 +12,24 @@
#include "../base/start_mem_debug.hpp"
namespace
void LoadMapHeader(FilesContainerR const & cont, feature::DataHeader & header)
{
void LoadHeader(FilesContainerR const & cont, feature::DataHeader & header)
{
ModelReaderPtr r = cont.GetReader(HEADER_FILE_TAG);
ModelReaderPtr r = cont.GetReader(HEADER_FILE_TAG);
if (cont.IsReaderExist(VERSION_FILE_TAG))
header.Load(r);
else
header.LoadVer1(r);
}
if (cont.IsReaderExist(VERSION_FILE_TAG))
header.Load(r);
else
header.LoadVer1(r);
}
void LoadMapHeader(ModelReader * pReader, feature::DataHeader & header)
{
LoadMapHeader(FilesContainerR(pReader), header);
}
void IndexFactory::Load(FilesContainerR const & cont)
{
LoadHeader(cont, m_header);
LoadMapHeader(cont, m_header);
}
IntervalIndexIFace * IndexFactory::CreateIndex(ModelReaderPtr reader)
@ -49,17 +51,3 @@ IntervalIndexIFace * IndexFactory::CreateIndex(ModelReaderPtr reader)
return p;
}
m2::RectD GetMapBounds(FilesContainerR const & cont)
{
feature::DataHeader header;
LoadHeader(cont, header);
return header.GetBounds();
}
pair<int, int> GetMapScaleRange(FilesContainerR const & cont)
{
feature::DataHeader header;
LoadHeader(cont, header);
return header.GetScaleRange();
}

View file

@ -19,5 +19,4 @@ public:
IntervalIndexIFace * CreateIndex(ModelReaderPtr reader);
};
m2::RectD GetMapBounds(FilesContainerR const & cont);
pair<int, int> GetMapScaleRange(FilesContainerR const & cont);
void LoadMapHeader(ModelReader * pReader, feature::DataHeader & header);

View file

@ -99,7 +99,10 @@ namespace
void RunFeaturesLoadingBenchmark(string const & file, size_t count, pair<int, int> scaleR)
{
pair<int, int> const r = GetMapScaleRange(FilesContainerR(GetPlatform().GetReader(file)));
feature::DataHeader header;
LoadMapHeader(GetPlatform().GetReader(file), header);
pair<int, int> const r = header.GetScaleRange();
if (r.first > scaleR.first)
scaleR.first = r.first;
if (r.second < scaleR.second)
@ -111,7 +114,7 @@ void RunFeaturesLoadingBenchmark(string const & file, size_t count, pair<int, in
model::FeaturesFetcher src;
src.AddMap(file);
m2::RectD const rect = GetMapBounds(FilesContainerR(GetPlatform().GetReader(file)));
m2::RectD const rect = header.GetBounds();
my::Timer timer;
double all = 0.0;

View file

@ -1,9 +1,12 @@
#include "api.hpp"
#include "../../indexer/classificator_loader.hpp"
#include "../../indexer/data_factory.hpp"
#include "../../platform/platform.hpp"
#include "../../std/iostream.hpp"
#include "../../3party/gflags/src/gflags/gflags.h"
@ -11,7 +14,7 @@ DEFINE_string(input, "", "MWM file name in the data directory");
DEFINE_int32(count, 3, "How many times to run benchmark");
DEFINE_int32(lowS, 10, "Low processing scale");
DEFINE_int32(highS, 17, "High processing scale");
DEFINE_bool(print_scales, false, "Print geometry scales for MWM");
int main(int argc, char ** argv)
{
@ -30,6 +33,16 @@ int main(int argc, char ** argv)
google::ParseCommandLineFlags(&argc, &argv, false);
if (FLAGS_print_scales)
{
feature::DataHeader h;
LoadMapHeader(pl.GetReader(FLAGS_input), h);
for (size_t i = 0; i < h.GetScalesCount(); ++i)
cout << h.GetScale(i) << " ";
cout << endl;
}
if (!FLAGS_input.empty())
{
RunFeaturesLoadingBenchmark(FLAGS_input, FLAGS_count,

View file

@ -45,7 +45,10 @@ void Framework<TModel>::AddMap(string const & file)
LOG(LDEBUG, ("Loading map:", file));
threads::MutexGuard lock(m_modelSyn);
m_model.AddWorldRect(GetMapBounds(FilesContainerR(GetPlatform().GetReader(file))));
feature::DataHeader h;
LoadMapHeader(GetPlatform().GetReader(file), h);
m_model.AddWorldRect(h.GetBounds());
m_model.AddMap(file);
}