Welcome to mirror list, hosted at ThFree Co, Russian Federation.

api.cpp « benchmark_tool « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cdf56b8bf9da6eb668c9c8bb283b02c6f18d8d9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "map/benchmark_tool/api.hpp"

#include "std/iostream.hpp"
#include "std/numeric.hpp"
#include "std/algorithm.hpp"
#include "std/iomanip.hpp"
#include "std/iterator.hpp"


namespace bench
{

void Result::PrintAllTimes()
{
  sort(m_time.begin(), m_time.end());
  copy(m_time.begin(), m_time.end(), std::ostream_iterator<double>(cout, ", "));
  cout << endl;
}

void Result::CalcMetrics()
{
  if (!m_time.empty())
  {
    sort(m_time.begin(), m_time.end());

    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();

  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;
  }
}

}