All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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.getAverage(); }
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: