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:
authorAlex Zolotarev <deathbaba@gmail.com>2011-03-20 06:20:31 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:13:54 +0300
commit3d2498ee2119e667580a54074126f7eff12f5aca (patch)
treecb35082737d6075de58b78ae5a1fe2b5b62cdcff /generator/statistics.cpp
parent1e7be338c611ee9f6ea8a2c139b2eb9ac242207f (diff)
- Created [generator],[generator_tests] and moved indexer_tool to [generator_tool]
Diffstat (limited to 'generator/statistics.cpp')
-rw-r--r--generator/statistics.cpp157
1 files changed, 157 insertions, 0 deletions
diff --git a/generator/statistics.cpp b/generator/statistics.cpp
new file mode 100644
index 0000000000..84c99ea74a
--- /dev/null
+++ b/generator/statistics.cpp
@@ -0,0 +1,157 @@
+#include "../base/SRC_FIRST.hpp"
+
+#include "statistics.hpp"
+
+#include "../indexer/feature_processor.hpp"
+#include "../indexer/classificator.hpp"
+#include "../indexer/feature_impl.hpp"
+
+#include "../base/string_utils.hpp"
+
+#include "../std/iostream.hpp"
+
+#include "../base/start_mem_debug.hpp"
+
+
+namespace stats
+{
+ void FileContainerStatistic(string const & fName)
+ {
+ FilesContainerR cont(fName);
+
+ vector<string> tags;
+ tags.push_back(DATA_FILE_TAG);
+ for (int i = 0; i < ARRAY_SIZE(feature::g_arrCountryScales); ++i)
+ {
+ tags.push_back(feature::GetTagForIndex(GEOMETRY_FILE_TAG, i));
+ tags.push_back(feature::GetTagForIndex(TRIANGLE_FILE_TAG, i));
+ }
+ tags.push_back(INDEX_FILE_TAG);
+
+ for (size_t i = 0; i < tags.size(); ++i)
+ cout << tags[i] << " : " << cont.GetReader(tags[i]).Size() << endl;
+ }
+
+ class AccumulateStatistic
+ {
+ MapInfo & m_info;
+
+ class ProcessType
+ {
+ MapInfo & m_info;
+ uint32_t m_size;
+
+ public:
+ ProcessType(MapInfo & info, uint32_t sz) : m_info(info), m_size(sz) {}
+ void operator() (uint32_t type)
+ {
+ m_info.AddToSet(TypeTag(type), m_size, m_info.m_byClassifType);
+ }
+ };
+
+ public:
+ AccumulateStatistic(MapInfo & info) : m_info(info) {}
+
+ void operator() (FeatureType const & f, uint32_t)
+ {
+ f.ParseBeforeStatistic();
+
+ FeatureType::inner_geom_stat_t const innerStats = f.GetInnerStatistic();
+
+ m_info.m_inner[0].Add(innerStats.m_Points);
+ m_info.m_inner[1].Add(innerStats.m_Strips);
+ m_info.m_inner[2].Add(innerStats.m_Size);
+
+ FeatureType::geom_stat_t const geom = f.GetGeometrySize(-1);
+ FeatureType::geom_stat_t const trg = f.GetTrianglesSize(-1);
+
+ m_info.AddToSet(geom.m_count, geom.m_size, m_info.m_byPointsCount);
+ m_info.AddToSet(trg.m_count / 3, trg.m_size, m_info.m_byTrgCount);
+
+ uint32_t const allSize = innerStats.m_Size + geom.m_size + trg.m_size;
+
+ m_info.AddToSet(f.GetFeatureType(), allSize, m_info.m_byGeomType);
+
+ ProcessType doProcess(m_info, allSize);
+ f.ForEachTypeRef(doProcess);
+ }
+ };
+
+ void CalcStatistic(string const & fName, MapInfo & info)
+ {
+ AccumulateStatistic doProcess(info);
+ feature::ForEachFromDat(fName, doProcess);
+ }
+
+ void PrintInfo(char const * prefix, GeneralInfo const & info)
+ {
+ cout << prefix << ": size = " << info.m_size << "; count = " << info.m_count << endl;
+ }
+
+ string GetKey(FeatureBase::FeatureType type)
+ {
+ switch (type)
+ {
+ case FeatureBase::FEATURE_TYPE_LINE: return "Line";
+ case FeatureBase::FEATURE_TYPE_AREA: return "Area";
+ default: return "Point";
+ }
+ }
+
+ string GetKey(uint32_t i)
+ {
+ return utils::to_string(i);
+ }
+
+ string GetKey(TypeTag t)
+ {
+ return classif().GetFullObjectName(t.m_val);
+ }
+
+ template <class TSortCr, class TSet>
+ void PrintTop(char const * prefix, TSet const & theSet)
+ {
+ cout << prefix << endl;
+
+ vector<typename TSet::value_type> vec(theSet.begin(), theSet.end());
+
+ sort(vec.begin(), vec.end(), TSortCr());
+
+ size_t const count = min(static_cast<size_t>(10), vec.size());
+ for (size_t i = 0; i < count; ++i)
+ {
+ cout << i << ". ";
+ PrintInfo(GetKey(vec[i].m_key).c_str(), vec[i].m_info);
+ }
+ }
+
+ struct greater_size
+ {
+ template <class TInfo>
+ bool operator() (TInfo const & r1, TInfo const & r2) const
+ {
+ return r1.m_info.m_size > r2.m_info.m_size;
+ }
+ };
+
+ struct greater_count
+ {
+ template <class TInfo>
+ bool operator() (TInfo const & r1, TInfo const & r2) const
+ {
+ return r1.m_info.m_count > r2.m_info.m_count;
+ }
+ };
+
+ void PrintStatistic(MapInfo & info)
+ {
+ PrintInfo("DAT header", info.m_inner[2]);
+ PrintInfo("Points header", info.m_inner[0]);
+ PrintInfo("Strips header", info.m_inner[1]);
+
+ PrintTop<greater_size>("Top SIZE by Geometry Type", info.m_byGeomType);
+ PrintTop<greater_size>("Top SIZE by Classificator Type", info.m_byClassifType);
+ PrintTop<greater_size>("Top SIZE by Points Count", info.m_byPointsCount);
+ PrintTop<greater_size>("Top SIZE by Triangles Count", info.m_byTrgCount);
+ }
+}