ratio.h
Go to the documentation of this file.
1 /* ratio.h
2  */
3 #ifndef _RATIO_H
4 #define _RATIO_H
5 
6 #include "osl/stat/average.h"
7 
8 namespace osl
9 {
10  namespace stat
11  {
12  class Ratio
13  {
15  const char *name;
17  public:
18  Ratio(const char *n=0, bool show=false) : name(n), show_on_destructor(show)
19  {
20  }
21  ~Ratio();
22  void add(bool success) { ave.add(success ? 1.0 : 0.0); }
23  double ratio() const { return ave.average(); }
24  void show() const;
25  void clear() { ave.clear(); }
26  };
27  } // namespace stat
28 } // namespace osl
29 
30 
31 #endif /* _RATIO_H */
32 // ;;; Local Variables:
33 // ;;; mode:c++
34 // ;;; c-basic-offset:2
35 // ;;; End:
bool show_on_destructor
Definition: ratio.h:16
double ratio() const
Definition: ratio.h:23
double add(const double &x)
Add an element x.
Definition: average.h:27
Ratio(const char *n=0, bool show=false)
Definition: ratio.h:18
void clear(double a=0.0, int e=0)
Definition: average.h:42
Average ave
Definition: ratio.h:14
incrementaly maintain average of data sequence
Definition: average.h:13
const char * name
Definition: ratio.h:15
void show() const
Definition: ratio.cc:19
void clear()
Definition: ratio.h:25
double average() const
Definition: average.h:48
void add(bool success)
Definition: ratio.h:22