1 /*
2  * Copyright (C) 2014 Codership Oy <info@codership.com>
3  */
4 
5 #ifndef _gu_stats_hpp_
6 #define _gu_stats_hpp_
7 
8 #include <ostream>
9 
10 namespace gu
11 {
12     class Stats
13     {
14     public:
Stats()15         Stats():n_(0),
16                 old_m_(), new_m_(),
17                 old_s_(), new_s_(),
18                 min_(), max_() {}
19         void insert(const double);
clear()20         void clear() {
21             n_ = 0;
22         }
times() const23         unsigned int times() const {
24             return n_;
25         }
26         double min() const;
27         double max() const;
28         double mean() const;
29         double variance() const;
30         double std_dev() const;
31         friend std::ostream& operator<<(std::ostream&, const Stats&);
32         std::string to_string() const;
33     private:
34         unsigned int n_;
35         double old_m_;
36         double new_m_;
37         double old_s_;
38         double new_s_;
39         double min_;
40         double max_;
41     };
42 
43     std::ostream& operator<<(std::ostream&, const Stats&);
44 }
45 
46 #endif // _gu_stats_hpp_
47