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

time_samples.cpp « base - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 209385b0606997468cce0af498a66ddd2f0435ba (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
#include "base/time_samples.hpp"

#include "std/cmath.hpp"

namespace my
{
void TimeSamples::Add(double seconds)
{
  m_sum += seconds;
  m_sum2 += seconds * seconds;
  ++m_total;
}

double TimeSamples::GetMean() const { return m_total == 0 ? 0.0 : m_sum / m_total; }

double TimeSamples::GetSD() const
{
  if (m_total < 2)
    return 0.0;
  return std::max((m_sum2 - m_sum * m_sum / static_cast<double>(m_total)) / (m_total - 1), 0.0);
}

double TimeSamples::GetVar() const { return sqrt(GetSD()); }
}  // namespace my