00001 00002 //============================================================================= 00003 /** 00004 * @file Basic_Stats.h 00005 * 00006 * Basic_Stats.h,v 4.7 2005/10/28 16:14:51 ossama Exp 00007 * 00008 * @author Carlos O'Ryan <coryan@uci.edu> 00009 */ 00010 //============================================================================= 00011 00012 00013 #ifndef ACE_BASIC_STATS_H 00014 #define ACE_BASIC_STATS_H 00015 #include /**/ "ace/pre.h" 00016 00017 #include "ace/config-all.h" 00018 #include "ace/Basic_Types.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00025 00026 /// Collect basic stats about a series of samples 00027 /** 00028 * Compute the average and standard deviation (aka jitter) for an 00029 * arbitrary number of samples, using constant space. 00030 * Normally used for latency statistics. 00031 */ 00032 class ACE_Export ACE_Basic_Stats 00033 { 00034 public: 00035 /// Constructor 00036 /** 00037 * The number of samples is pre-allocated, and cannot changes once 00038 * the class is initialized. 00039 */ 00040 ACE_Basic_Stats (void); 00041 00042 /// The number of samples received so far 00043 ACE_UINT32 samples_count (void) const; 00044 00045 /// Record one sample. 00046 void sample (ACE_UINT64 value); 00047 00048 /// Update the values to reflect the stats in @a rhs. 00049 void accumulate (const ACE_Basic_Stats &rhs); 00050 00051 /// Dump all the samples 00052 /** 00053 * Prints out the results, using @a msg as a prefix for each message and 00054 * scaling all the numbers by @a scale_factor. The latter is useful because 00055 * high resolution timer samples are acquired in clock ticks, but often 00056 * presented in microseconds. 00057 */ 00058 void dump_results (const ACE_TCHAR *msg, 00059 ACE_UINT32 scale_factor) const; 00060 00061 /// The number of samples 00062 ACE_UINT32 samples_count_; 00063 00064 /// The minimum value 00065 ACE_UINT64 min_; 00066 00067 /// The number of the sample that had the minimum value 00068 ACE_UINT32 min_at_; 00069 00070 /// The maximum value 00071 ACE_UINT64 max_; 00072 00073 /// The number of the sample that had the maximum value 00074 ACE_UINT32 max_at_; 00075 00076 /// The sum of all the values 00077 ACE_UINT64 sum_; 00078 }; 00079 00080 ACE_END_VERSIONED_NAMESPACE_DECL 00081 00082 #if defined (__ACE_INLINE__) 00083 #include "ace/Basic_Stats.inl" 00084 #endif /* __ACE_INLINE__ */ 00085 00086 #include /**/ "ace/post.h" 00087 #endif /* ACE_BASIC_STATS_H */