00001 00002 //============================================================================= 00003 /** 00004 * @file Basic_Stats.h 00005 * 00006 * $Id: Basic_Stats.h,v 1.1.1.2 2003/02/21 18:36:32 chad 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 /// Collect basic stats about a series of samples 00025 /** 00026 * Compute the average and standard deviation (aka jitter) for an 00027 * arbitrary number of samples, using constant space. 00028 * Normally used for latency statistics. 00029 */ 00030 class ACE_Export ACE_Basic_Stats 00031 { 00032 public: 00033 /// Constructor 00034 /** 00035 * The number of samples is pre-allocated, and cannot changes once 00036 * the class is initialized. 00037 */ 00038 ACE_Basic_Stats (void); 00039 00040 /// The number of samples received so far 00041 ACE_UINT32 samples_count (void) const; 00042 00043 /// Record one sample. 00044 void sample (ACE_UINT64 value); 00045 00046 /// Update the values to reflect the stats in @a rhs. 00047 void accumulate (const ACE_Basic_Stats &rhs); 00048 00049 /// Dump all the samples 00050 /** 00051 * Prints out the results, using @a msg as a prefix for each message and 00052 * scaling all the numbers by @a scale_factor. The latter is useful because 00053 * high resolution timer samples are acquired in clock ticks, but often 00054 * presented in microseconds. 00055 */ 00056 void dump_results (const ACE_TCHAR *msg, 00057 ACE_UINT32 scale_factor) const; 00058 00059 private: 00060 /// The number of samples 00061 ACE_UINT32 samples_count_; 00062 00063 /// The minimum value 00064 ACE_UINT64 min_; 00065 00066 /// The number of the sample that had the minimum value 00067 ACE_UINT32 min_at_; 00068 00069 /// The maximum value 00070 ACE_UINT64 max_; 00071 00072 /// The number of the sample that had the maximum value 00073 ACE_UINT32 max_at_; 00074 00075 /// The sum of all the values 00076 ACE_UINT64 sum_; 00077 00078 /// The sum of the square of all the values 00079 ACE_UINT64 sum2_; 00080 }; 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 */
1.2.14 written by Dimitri van Heesch,
© 1997-2002