00001 /* ratio.h 00002 */ 00003 #ifndef _RATIO_H 00004 #define _RATIO_H 00005 00006 #include "osl/stat/average.h" 00007 00008 namespace osl 00009 { 00010 namespace stat 00011 { 00012 class Ratio 00013 { 00014 Average ave; 00015 const char *name; 00016 bool show_on_destructor; 00017 public: 00018 Ratio(const char *n=0, bool show=false) : name(n), show_on_destructor(show) 00019 { 00020 } 00021 ~Ratio(); 00022 void add(bool success) { ave.add(success ? 1.0 : 0.0); } 00023 double ratio() const { return ave.average(); } 00024 void show() const; 00025 void clear() { ave.clear(); } 00026 }; 00027 } // namespace stat 00028 } // namespace osl 00029 00030 00031 #endif /* _RATIO_H */ 00032 // ;;; Local Variables: 00033 // ;;; mode:c++ 00034 // ;;; c-basic-offset:2 00035 // ;;; End: