Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2011-08-29 13:25:45 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:22:40 +0300
commit4b54e80d560eb7b07cfcf60fba7484ae04733813 (patch)
tree5b4176298275feeabda0c6928bcd20ffe2e6c1ac /map/benchmark_tool
parentaca3014c79bbaaab7afd09f0971bfddfa1f49dda (diff)
Fix ForEachFeature benchmarking and add additional scale params.
Diffstat (limited to 'map/benchmark_tool')
-rw-r--r--map/benchmark_tool/api.hpp3
-rw-r--r--map/benchmark_tool/features_loading.cpp67
-rw-r--r--map/benchmark_tool/main.cpp19
3 files changed, 64 insertions, 25 deletions
diff --git a/map/benchmark_tool/api.hpp b/map/benchmark_tool/api.hpp
index 1e9b56ebfa..c25ad02fab 100644
--- a/map/benchmark_tool/api.hpp
+++ b/map/benchmark_tool/api.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "../../std/string.hpp"
+#include "../../std/utility.hpp"
/// @param[in] count number of times to run benchmark
-void RunFeaturesLoadingBenchmark(string const & file, size_t count);
+void RunFeaturesLoadingBenchmark(string const & file, size_t count, pair<int, int> scaleR);
diff --git a/map/benchmark_tool/features_loading.cpp b/map/benchmark_tool/features_loading.cpp
index d8914d12f9..dfa1652b50 100644
--- a/map/benchmark_tool/features_loading.cpp
+++ b/map/benchmark_tool/features_loading.cpp
@@ -5,6 +5,7 @@
#include "../feature_vec_model.hpp"
#include "../../indexer/data_factory.hpp"
+#include "../../indexer/feature_visibility.hpp"
#include "../../platform/platform.hpp"
@@ -20,9 +21,9 @@ namespace
{
class Accumulator
{
- mutable my::Timer m_timer;
- mutable double m_reading;
- mutable size_t m_count;
+ my::Timer m_timer;
+ double m_reading;
+ size_t m_count;
int m_scale;
@@ -39,58 +40,78 @@ namespace
double GetReadingTime() const { return m_reading; }
- void operator() (FeatureType const & ft) const
+ void operator() (FeatureType const & ft)
{
++m_count;
m_timer.Reset();
- // Call this function to load feature's inner data and geometry.
- (void)ft.IsEmptyGeometry(m_scale);
+ vector<drule::Key> keys;
+ string names; // for debug use only, in release it's empty
+ (void)feature::GetDrawRule(ft, m_scale, keys, names);
+
+ if (!keys.empty())
+ {
+ // Call this function to load feature's inner data and geometry.
+ (void)ft.IsEmptyGeometry(m_scale);
+ }
m_reading += m_timer.ElapsedSeconds();
}
};
double RunBenchmark(model::FeaturesFetcher const & src, m2::RectD const & rect,
- pair<int, int> const & scaleRange)
+ pair<int, int> const & scaleR)
{
- vector<m2::RectD> rects, newRects;
- rects.push_back(rect);
+ ASSERT_LESS_OR_EQUAL ( scaleR.first, scaleR.second, () );
+ vector<m2::RectD> rects;
+ rects.push_back(rect);
Accumulator acc;
- for (int scale = scaleRange.first; scale < scaleRange.second; ++scale)
+ while (!rects.empty())
{
- for (size_t i = 0; i < rects.size(); ++i)
- {
- m2::RectD const r = rects[i];
+ m2::RectD const r = rects.back();
+ rects.pop_back();
+ bool doDivide = true;
+ int const scale = scales::GetScaleLevel(r);
+ if (scale >= scaleR.first)
+ {
acc.Reset(scale);
+ src.ForEachFeature(r, acc, scale);
+ doDivide = !acc.IsEmpty();
+ }
- src.ForEachFeature_TileDrawing(r, acc, scale);
-
+ if (doDivide && scale < scaleR.second)
+ {
m2::RectD r1, r2;
r.DivideByGreaterSize(r1, r2);
- newRects.push_back(r1);
- newRects.push_back(r2);
+ rects.push_back(r1);
+ rects.push_back(r2);
}
- rects.swap(newRects);
- newRects.clear();
}
+
return acc.GetReadingTime();
}
}
-void RunFeaturesLoadingBenchmark(string const & file, size_t count)
+void RunFeaturesLoadingBenchmark(string const & file, size_t count, pair<int, int> scaleR)
{
+ pair<int, int> const r = GetMapScaleRange(FilesContainerR(GetPlatform().GetReader(file)));
+ if (r.first > scaleR.first)
+ scaleR.first = r.first;
+ if (r.second < scaleR.second)
+ scaleR.second = r.second;
+
+ if (scaleR.first > scaleR.second)
+ return;
+
model::FeaturesFetcher src;
- src.InitClassificator();
src.AddMap(file);
m2::RectD const rect = GetMapBounds(FilesContainerR(GetPlatform().GetReader(file)));
- pair<int, int> const scaleRange = GetMapScaleRange(FilesContainerR(GetPlatform().GetReader(file)));
my::Timer timer;
double all = 0.0;
@@ -100,7 +121,7 @@ void RunFeaturesLoadingBenchmark(string const & file, size_t count)
{
timer.Reset();
- reading += RunBenchmark(src, rect, scaleRange);
+ reading += RunBenchmark(src, rect, scaleR);
all += timer.ElapsedSeconds();
}
diff --git a/map/benchmark_tool/main.cpp b/map/benchmark_tool/main.cpp
index 8e9d5cbc89..32746895e1 100644
--- a/map/benchmark_tool/main.cpp
+++ b/map/benchmark_tool/main.cpp
@@ -1,12 +1,26 @@
#include "api.hpp"
+#include "../../indexer/classificator_loader.hpp"
+
+#include "../../platform/platform.hpp"
+
#include "../../3party/gflags/src/gflags/gflags.h"
+
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");
+
int main(int argc, char ** argv)
{
+ Platform & pl = GetPlatform();
+ classificator::Read(pl.GetReader("drawing_rules.bin"),
+ pl.GetReader("classificator.txt"),
+ pl.GetReader("visibility.txt"),
+ pl.GetReader("types.txt"));
+
google::SetUsageMessage("MWM benchmarking tool");
if (argc < 2)
{
@@ -17,7 +31,10 @@ int main(int argc, char ** argv)
google::ParseCommandLineFlags(&argc, &argv, false);
if (!FLAGS_input.empty())
- RunFeaturesLoadingBenchmark(FLAGS_input, FLAGS_count);
+ {
+ RunFeaturesLoadingBenchmark(FLAGS_input, FLAGS_count,
+ make_pair(FLAGS_lowS, FLAGS_highS));
+ }
return 0;
}