| 26 | Stats(size_t logCallCountThreshold) : m_timer(true /* start */), m_logCallCountThreshold(logCallCountThreshold) {} |
| 27 | |
| 28 | void Log(std::vector<OsmElement> const & elements, uint64_t pos, bool forcePrint = false) |
| 29 | { |
| 30 | for (auto const & e : elements) |
| 31 | if (e.IsNode()) |
| 32 | ++m_nodeCounter; |
| 33 | else if (e.IsWay()) |
| 34 | ++m_wayCounter; |
| 35 | else if (e.IsRelation()) |
| 36 | ++m_relationCounter; |
| 37 | |
| 38 | m_element_counter += elements.size(); |
| 39 | if (!forcePrint && m_callCount != m_logCallCountThreshold) |
| 40 | { |
| 41 | ++m_callCount; |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | auto static constexpr kBytesInMiB = 1024.0 * 1024.0; |
| 46 | auto const posMiB = pos / kBytesInMiB; |
| 47 | auto const elapsedSeconds = m_timer.ElapsedSeconds(); |
| 48 | auto const avgSpeedMiBPerSec = posMiB / elapsedSeconds; |
| 49 | auto const speedMiBPerSec = (pos - m_prevFilePos) / (elapsedSeconds - m_prevElapsedSeconds) / kBytesInMiB; |
| 50 | |
| 51 | LOG(LINFO, ("Read", m_element_counter, "elements [pos:", posMiB, "MiB, avg read speed:", avgSpeedMiBPerSec, |
| 52 | " MiB/s, read speed:", speedMiBPerSec, "MiB/s [n:", m_nodeCounter, ", w:", m_wayCounter, |
| 53 | ", r:", m_relationCounter, "]]")); |
| 54 | |
| 55 | m_prevFilePos = pos; |
| 56 | m_prevElapsedSeconds = elapsedSeconds; |
| 57 | m_nodeCounter = 0; |
| 58 | m_wayCounter = 0; |
| 59 | m_relationCounter = 0; |
| 60 | m_callCount = 0; |
| 61 | } |
| 62 | |
| 63 | private: |
| 64 | base::Timer m_timer; |
no test coverage detected