diff options
author | VladiMihaylenko <vxmihaylenko@gmail.com> | 2018-11-07 18:14:43 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <bykoianko@gmail.com> | 2018-11-08 16:21:01 +0300 |
commit | dd5d537e7ecd33517eb80e6efd3ddaf64cacc2d8 (patch) | |
tree | 108ee92f4604966ad6823b8aef57555440fe1db3 /track_analyzing | |
parent | 98916a85691fcab246f7530972654e3c1c5922ab (diff) |
Made track analyzer a little bit faster.
Diffstat (limited to 'track_analyzing')
-rw-r--r-- | track_analyzing/track_analyzer/cmd_gpx.cpp | 6 | ||||
-rw-r--r-- | track_analyzing/track_analyzer/cmd_match.cpp | 17 | ||||
-rw-r--r-- | track_analyzing/track_analyzer/cmd_unmatched_tracks.cpp | 6 | ||||
-rw-r--r-- | track_analyzing/track_analyzer/utils.cpp | 4 | ||||
-rw-r--r-- | track_analyzing/track_analyzer/utils.hpp | 4 |
5 files changed, 21 insertions, 16 deletions
diff --git a/track_analyzing/track_analyzer/cmd_gpx.cpp b/track_analyzing/track_analyzer/cmd_gpx.cpp index 257d21f800..af72b2aac5 100644 --- a/track_analyzing/track_analyzer/cmd_gpx.cpp +++ b/track_analyzing/track_analyzer/cmd_gpx.cpp @@ -3,6 +3,7 @@ #include "routing_common/num_mwm_id.hpp" +#include "storage/routing_helpers.hpp" #include "storage/storage.hpp" #include "coding/file_name_utils.hpp" @@ -27,10 +28,11 @@ void CmdGPX(string const & logFile, string const & outputDirName, string const & return; } - shared_ptr<NumMwmIds> numMwmIds; storage::Storage storage; + storage.RegisterAllLocalMaps(false /* enableDiffs */); + shared_ptr<NumMwmIds> numMwmIds = CreateNumMwmIds(storage); MwmToTracks mwmToTracks; - ParseTracks(logFile, numMwmIds, storage, mwmToTracks); + ParseTracks(logFile, numMwmIds, mwmToTracks); for (auto const & kv : mwmToTracks) { auto const & mwmName = numMwmIds->GetFile(kv.first).GetName(); diff --git a/track_analyzing/track_analyzer/cmd_match.cpp b/track_analyzing/track_analyzer/cmd_match.cpp index 2b0a2de3c7..883e77a915 100644 --- a/track_analyzing/track_analyzer/cmd_match.cpp +++ b/track_analyzing/track_analyzer/cmd_match.cpp @@ -6,6 +6,7 @@ #include "routing_common/num_mwm_id.hpp" +#include "storage/routing_helpers.hpp" #include "storage/storage.hpp" #include "coding/file_name_utils.hpp" @@ -89,10 +90,10 @@ void MatchTracks(MwmToTracks const & mwmToTracks, storage::Storage const & stora namespace track_analyzing { -void CmdMatch(string const & logFile, string const & trackFile, shared_ptr<NumMwmIds> numMwmIds, Storage & storage) +void CmdMatch(string const & logFile, string const & trackFile, shared_ptr<NumMwmIds> const & numMwmIds, Storage const & storage) { MwmToTracks mwmToTracks; - ParseTracks(logFile, numMwmIds, storage, mwmToTracks); + ParseTracks(logFile, numMwmIds, mwmToTracks); MwmToMatchedTracks mwmToMatchedTracks; MatchTracks(mwmToTracks, storage, *numMwmIds, mwmToMatchedTracks); @@ -106,14 +107,17 @@ void CmdMatch(string const & logFile, string const & trackFile, shared_ptr<NumMw void CmdMatch(string const & logFile, string const & trackFile) { LOG(LINFO, ("Matching", logFile)); - shared_ptr<NumMwmIds> numMwmIds; Storage storage; + storage.RegisterAllLocalMaps(false /* enableDiffs */); + shared_ptr<NumMwmIds> numMwmIds = CreateNumMwmIds(storage); CmdMatch(logFile, trackFile, numMwmIds, storage); } -void UnzipAndMatch(Iter begin, Iter end, string const & trackExt, shared_ptr<NumMwmIds> numMwmIds) +void UnzipAndMatch(Iter begin, Iter end, string const & trackExt) { Storage storage; + storage.RegisterAllLocalMaps(false /* enableDiffs */); + shared_ptr<NumMwmIds> numMwmIds = CreateNumMwmIds(storage); for (auto it = begin; it != end; ++it) { auto & file = *it; @@ -181,7 +185,6 @@ void CmdMatchDir(string const & logDir, string const & trackExt) return; } - shared_ptr<NumMwmIds> numMwmIds; auto const size = filesList.size(); auto const hardwareConcurrency = static_cast<size_t>(thread::hardware_concurrency()); CHECK_GREATER(hardwareConcurrency, 0, ("No available threads.")); @@ -193,11 +196,11 @@ void CmdMatchDir(string const & logDir, string const & trackExt) for (size_t i = 0; i < threadsCount - 1; ++i) { auto end = begin + blockSize; - threads[i] = thread(UnzipAndMatch, begin, end, trackExt, numMwmIds); + threads[i] = thread(UnzipAndMatch, begin, end, trackExt); begin = end; } - UnzipAndMatch(begin, filesList.end(), trackExt, numMwmIds); + UnzipAndMatch(begin, filesList.end(), trackExt); for (auto & t : threads) t.join(); } diff --git a/track_analyzing/track_analyzer/cmd_unmatched_tracks.cpp b/track_analyzing/track_analyzer/cmd_unmatched_tracks.cpp index ab5a24389a..ef96a6f4fa 100644 --- a/track_analyzing/track_analyzer/cmd_unmatched_tracks.cpp +++ b/track_analyzing/track_analyzer/cmd_unmatched_tracks.cpp @@ -3,6 +3,7 @@ #include "routing_common/num_mwm_id.hpp" +#include "storage/routing_helpers.hpp" #include "storage/storage.hpp" #include "base/logging.hpp" @@ -19,10 +20,11 @@ using namespace std; void CmdUnmatchedTracks(string const & logFile, string const & trackFileCsv) { LOG(LINFO, ("Saving unmatched tracks", logFile)); - shared_ptr<NumMwmIds> numMwmIds; storage::Storage storage; + storage.RegisterAllLocalMaps(false /* enableDiffs */); + shared_ptr<NumMwmIds> numMwmIds = CreateNumMwmIds(storage); MwmToTracks mwmToTracks; - ParseTracks(logFile, numMwmIds, storage, mwmToTracks); + ParseTracks(logFile, numMwmIds, mwmToTracks); string const sep = ","; ofstream ofs(trackFileCsv, std::ofstream::out); diff --git a/track_analyzing/track_analyzer/utils.cpp b/track_analyzing/track_analyzer/utils.cpp index a64ac2beab..899c4d5c12 100644 --- a/track_analyzing/track_analyzer/utils.cpp +++ b/track_analyzing/track_analyzer/utils.cpp @@ -17,11 +17,9 @@ using namespace routing; using namespace std; using namespace storage; -void ParseTracks(string const & logFile, shared_ptr<NumMwmIds> & numMwmIds, Storage & storage, +void ParseTracks(string const & logFile, shared_ptr<NumMwmIds> const & numMwmIds, MwmToTracks & mwmToTracks) { - storage.RegisterAllLocalMaps(false /* enableDiffs */); - numMwmIds = CreateNumMwmIds(storage); Platform const & platform = GetPlatform(); string const dataDir = platform.WritableDir(); unique_ptr<CountryInfoGetter> countryInfoGetter = diff --git a/track_analyzing/track_analyzer/utils.hpp b/track_analyzing/track_analyzer/utils.hpp index 7d8a7e6ca0..6edbb0e7d9 100644 --- a/track_analyzing/track_analyzer/utils.hpp +++ b/track_analyzing/track_analyzer/utils.hpp @@ -13,6 +13,6 @@ namespace track_analyzing { /// \brief Parses tracks from |logFile| and fills |numMwmIds|, |storage| and |mwmToTracks|. -void ParseTracks(std::string const & logFile, std::shared_ptr<routing::NumMwmIds> & numMwmIds, - storage::Storage & storage, MwmToTracks & mwmToTracks); +void ParseTracks(std::string const & logFile, std::shared_ptr<routing::NumMwmIds> const & numMwmIds, + MwmToTracks & mwmToTracks); } // namespace track_analyzing |