From a081d2e5c2d5a24c4e8822f3cdd06e2ac09cfbca Mon Sep 17 00:00:00 2001 From: rachytski Date: Sun, 12 Jun 2011 00:39:25 +0300 Subject: [PATCH] correct MWM enumeration code in benchmark mode. --- data/benchmark.info | 3 ++ data/benchmark.results | 2 - data/benchmark_stats.py | 16 +++---- map/framework.cpp | 103 ++++++++++++++++++++++++++++------------ 4 files changed, 83 insertions(+), 41 deletions(-) create mode 100644 data/benchmark.info delete mode 100644 data/benchmark.results diff --git a/data/benchmark.info b/data/benchmark.info new file mode 100644 index 0000000000..5518e39006 --- /dev/null +++ b/data/benchmark.info @@ -0,0 +1,3 @@ +Belarus.mwm Belarus 10 +Belarus.mwm Minsk 27.3271 64.1124 27.7853 64.3744 17 +Baden-Wurttemberg.mwm Stuttgart 9.04623 55.9417 9.32768 56.1027 17 \ No newline at end of file diff --git a/data/benchmark.results b/data/benchmark.results deleted file mode 100644 index 1f16ca664b..0000000000 --- a/data/benchmark.results +++ /dev/null @@ -1,2 +0,0 @@ -Belarus.mwm 10 -Minsk 27.3271 64.1124 27.7853 64.3744 17 diff --git a/data/benchmark_stats.py b/data/benchmark_stats.py index f77c48a996..f0d0f68ef0 100644 --- a/data/benchmark_stats.py +++ b/data/benchmark_stats.py @@ -8,21 +8,19 @@ lns1 = [l.split(" ") for l in lns1] bench_cfg = {} for l in lns1: - c_name = l[0] - is_country = False - if c_name.find(".") <> -1: - is_country = True - bench_cfg[l[0]] = [] - bench_cfg[l[0]].append(is_country) + c_name = l[1] + is_country = (len(l) == 3) + bench_cfg[l[1]] = [] + bench_cfg[l[1]].append(is_country) if len(l) > 0: if not is_country: - bench_cfg[c_name].append(float(l[1])) bench_cfg[c_name].append(float(l[2])) bench_cfg[c_name].append(float(l[3])) bench_cfg[c_name].append(float(l[4])) - bench_cfg[c_name].append(int(l[5])) + bench_cfg[c_name].append(float(l[5])) + bench_cfg[c_name].append(int(l[6])) else: - bench_cfg[c_name].append(int(l[1])) + bench_cfg[c_name].append(int(l[2])) f = open(sys.argv[1], "r") lns = f.readlines() diff --git a/map/framework.cpp b/map/framework.cpp index c916e846dd..3db3b89737 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -17,6 +17,7 @@ #include "../indexer/drawing_rules.hpp" #include "../base/math.hpp" +#include "../base/string_utils.hpp" #include "../std/algorithm.hpp" #include "../std/fstream.hpp" @@ -520,8 +521,30 @@ void FrameWork::AddRedrawCommandSure() template void FrameWork::EnumBenchmarkMaps(Platform::FilesList & filesList) { + set files; + ifstream fin(GetPlatform().WritablePathForFile("benchmark.info").c_str()); + filesList.clear(); - filesList.push_back(GetPlatform().ReadPathForFile("Belarus.mwm")); + char buf[256]; + + while (true) + { + fin.getline(buf, 256); + + if (!fin) + break; + + vector parts; + string s(buf); + strings::SimpleTokenizer it(s, " "); + while (it) + { + parts.push_back(*it); + ++it; + } + + filesList.push_back(GetPlatform().ReadPathForFile(parts[0])); + } } template @@ -530,49 +553,69 @@ void FrameWork::AddRedrawCommandSure() //m2::RectD wr(MercatorBounds::minX, MercatorBounds::minY, MercatorBounds::maxX, MercatorBounds::maxY); //m2::RectD r(wr.Center().x, wr.Center().y + wr.SizeY() / 8, wr.Center().x + wr.SizeX() / 8, wr.Center().y + wr.SizeY() / 4); - ifstream fin(GetPlatform().WritablePathForFile("benchmark.results").c_str()); + set files; + ifstream fin(GetPlatform().WritablePathForFile("benchmark.info").c_str()); while (true) { string name; m2::RectD r; - fin >> name; + char buf[256]; + + fin.getline(buf, 256); if (!fin) break; - if (GetPlatform().IsFileExists(GetPlatform().WritablePathForFile(name))) + vector parts; + string s(buf); + strings::SimpleTokenizer it(s, " "); + while (it) { - try - { - feature::DataHeader header; - header.Load(FilesContainerR(GetPlatform().WritablePathForFile(name)).GetReader(HEADER_FILE_TAG)); - - r = header.GetBounds(); - } - catch (std::exception const &) - { - double x0, y0, x1, y1; - fin >> x0 >> y0 >> x1 >> y1; - r = m2::RectD(x0, y0, x1, y1); - } + parts.push_back(*it); + ++it; } - else - { - double x0, y0, x1, y1; - fin >> x0 >> y0 >> x1 >> y1; - r = m2::RectD(x0, y0, x1, y1); - } - - if (!fin) - break; - - int lastScale; - fin >> lastScale; Benchmark b; - b.m_name = name; + b.m_name = parts[1]; + + if (files.find(parts[0]) == files.end()) + { + files.insert(parts[0]); + if (GetPlatform().IsFileExists(GetPlatform().WritablePathForFile(parts[0]))) + { + try + { + feature::DataHeader header; + header.Load(FilesContainerR(GetPlatform().WritablePathForFile(parts[0])).GetReader(HEADER_FILE_TAG)); + + r = header.GetBounds(); + } + catch (std::exception const &) + { + LOG(LINFO, ("cannot add ", parts[0], " file to benchmark")); + } + } + } + + int lastScale; + + LOG(LINFO, (parts)); + if (parts.size() > 3) + { + double x0, y0, x1, y1; + strings::to_double(parts[2], x0); + strings::to_double(parts[3], y0); + strings::to_double(parts[4], x1); + strings::to_double(parts[5], y1); + r = m2::RectD(x0, y0, x1, y1); + strings::to_int(parts[6], lastScale); + } + else + strings::to_int(parts[2], lastScale); + b.m_provider.reset(new BenchmarkRectProvider(scales::GetScaleLevel(r), r, lastScale)); + m_benchmarks.push_back(b); }