diff --git a/map/benchmark_tool/api.cpp b/map/benchmark_tool/api.cpp index 7f16e8cb56..db088a47af 100644 --- a/map/benchmark_tool/api.cpp +++ b/map/benchmark_tool/api.cpp @@ -4,32 +4,54 @@ #include "../../std/numeric.hpp" #include "../../std/algorithm.hpp" #include "../../std/iomanip.hpp" +#include "../../std/iterator.hpp" + namespace bench { -void Result::CalcMetrics() +void Result::PrintAllTimes() { sort(m_time.begin(), m_time.end()); + copy(m_time.begin(), m_time.end(), std::ostream_iterator(cout, ", ")); + cout << endl; +} - m_max = m_time.back(); - m_med = m_time[m_time.size()/2]; - m_all = accumulate(m_time.begin(), m_time.end(), 0.0); - m_avg = m_all / m_time.size(); +void Result::CalcMetrics() +{ + if (!m_time.empty()) + { + sort(m_time.begin(), m_time.end()); - m_time.clear(); + m_max = m_time.back(); + m_med = m_time[m_time.size()/2]; + m_all = accumulate(m_time.begin(), m_time.end(), 0.0); + m_avg = m_all / m_time.size(); + + m_time.clear(); + } + else + m_all = -1.0; } void AllResult::Print() { + //m_reading.PrintAllTimes(); m_reading.CalcMetrics(); - // 'all time', 'index time', 'feature loading time' - cout << fixed << setprecision(10); - cout << "FRAME*1000[ median:" << m_reading.m_med * 1000 << " "; - cout << "avg:" << m_reading.m_avg * 1000 << " "; - cout << "max:" << m_reading.m_max * 1000 << " ] "; - cout << "TOTAL[ idx:" << m_all - m_reading.m_all << " decoding:" << m_reading.m_all << " summ:" << m_all << " ]" << endl; + if (m_all < 0.0) + cout << "No frames" << endl; + else + { + cout << fixed << setprecision(10); + size_t const count = 1000; + cout << "FRAME*1000[ median:" << m_reading.m_med * count << + " avg:" << m_reading.m_avg * count << + " max:" << m_reading.m_max * count << " ] "; + cout << "TOTAL[ idx:" << m_all - m_reading.m_all << + " decoding:" << m_reading.m_all << + " summ:" << m_all << " ]" << endl; + } } } diff --git a/map/benchmark_tool/api.hpp b/map/benchmark_tool/api.hpp index b7e7f556c6..b552c10686 100644 --- a/map/benchmark_tool/api.hpp +++ b/map/benchmark_tool/api.hpp @@ -24,6 +24,7 @@ namespace bench m_time.insert(m_time.end(), r.m_time.begin(), r.m_time.end()); } + void PrintAllTimes(); void CalcMetrics(); };