#include <Basic_Stats.h>
Inheritance diagram for ACE_Basic_Stats:

Public Methods | |
| ACE_Basic_Stats (void) | |
| Constructor. More... | |
| ACE_UINT32 | samples_count (void) const |
| The number of samples received so far. More... | |
| void | sample (ACE_UINT64 value) |
| Record one sample. More... | |
| void | accumulate (const ACE_Basic_Stats &rhs) |
| Update the values to reflect the stats in rhs. More... | |
| void | dump_results (const ACE_TCHAR *msg, ACE_UINT32 scale_factor) const |
| Dump all the samples. More... | |
Private Attributes | |
| ACE_UINT32 | samples_count_ |
| The number of samples. More... | |
| ACE_UINT64 | min_ |
| The minimum value. More... | |
| ACE_UINT32 | min_at_ |
| The number of the sample that had the minimum value. More... | |
| ACE_UINT64 | max_ |
| The maximum value. More... | |
| ACE_UINT32 | max_at_ |
| The number of the sample that had the maximum value. More... | |
| ACE_UINT64 | sum_ |
| The sum of all the values. More... | |
| ACE_UINT64 | sum2_ |
| The sum of the square of all the values. More... | |
Compute the average and standard deviation (aka jitter) for an arbitrary number of samples, using constant space. Normally used for latency statistics.
Definition at line 30 of file Basic_Stats.h.
|
|
Constructor. The number of samples is pre-allocated, and cannot changes once the class is initialized. Definition at line 4 of file Basic_Stats.inl.
|
|
|
Update the values to reflect the stats in rhs.
Definition at line 14 of file Basic_Stats.cpp. References max_, min_, samples_count_, sum2_, and sum_. Referenced by ACE_Throughput_Stats::accumulate.
00015 {
00016 if (rhs.samples_count_ == 0)
00017 return;
00018
00019 if (this->samples_count_ == 0)
00020 {
00021 this->samples_count_ = rhs.samples_count_;
00022
00023 this->min_ = rhs.min_;
00024 this->max_ = rhs.max_;
00025 this->sum_ = rhs.sum_;
00026 this->sum2_ = rhs.sum2_;
00027
00028 return;
00029 }
00030 this->samples_count_ += rhs.samples_count_;
00031
00032 if (this->min_ > rhs.min_)
00033 this->min_ = rhs.min_;
00034 if (this->max_ < rhs.max_)
00035 this->max_ = rhs.max_;
00036
00037 this->sum_ += rhs.sum_;
00038 this->sum2_ += rhs.sum2_;
00039 }
|
|
||||||||||||
|
Dump all the samples. Prints out the results, using msg as a prefix for each message and scaling all the numbers by scale_factor. The latter is useful because high resolution timer samples are acquired in clock ticks, but often presented in microseconds. Definition at line 42 of file Basic_Stats.cpp. References ACE_CU64_TO_CU32, ACE_DEBUG, ACE_LIB_TEXT, ACE_TCHAR, ACE_U64_TO_U32, ACE_UINT64, LM_DEBUG, samples_count, samples_count_, sum2_, and sum_. Referenced by ACE_Throughput_Stats::dump_results.
00044 {
00045 if (this->samples_count () == 0u)
00046 {
00047 ACE_DEBUG ((LM_DEBUG,
00048 ACE_LIB_TEXT ("%s : no data collected\n"), msg));
00049 return;
00050 }
00051
00052 ACE_UINT64 avg = this->sum_ / this->samples_count_;
00053 ACE_UINT64 dev =
00054 #if defined ACE_LACKS_LONGLONG_T
00055 ACE_static_cast (ACE_U_LongLong,
00056 this->sum2_ / this->samples_count_)
00057 - avg * ACE_U64_TO_U32(avg);
00058 #else /* ! ACE_LACKS_LONGLONG_T */
00059 this->sum2_ / this->samples_count_ - avg * avg;
00060 #endif /* ! ACE_LACKS_LONGLONG_T */
00061
00062 double l_min = ACE_CU64_TO_CU32 (this->min_) / sf;
00063 double l_max = ACE_CU64_TO_CU32 (this->max_) / sf;
00064 double l_avg = ACE_CU64_TO_CU32 (avg) / sf;
00065 double l_dev = ACE_CU64_TO_CU32 (dev) / (sf * sf);
00066
00067 ACE_DEBUG ((LM_DEBUG,
00068 ACE_LIB_TEXT ("%s latency : %.2f[%d]/%.2f/%.2f[%d]/%.2f (min/avg/max/var^2)\n"),
00069 msg,
00070 l_min, this->min_at_,
00071 l_avg,
00072 l_max, this->max_at_,
00073 l_dev));
00074 }
|
|
|
Record one sample.
Definition at line 22 of file Basic_Stats.inl. References ACE_U64_TO_U32, ACE_UINT64, max_, max_at_, min_, min_at_, samples_count_, sum2_, and sum_. Referenced by ACE_Sample_History::collect_basic_stats, and ACE_Throughput_Stats::sample.
00023 {
00024 ++this->samples_count_;
00025
00026 if (this->samples_count_ == 1u)
00027 {
00028 this->min_ = value;
00029 this->min_at_ = this->samples_count_;
00030 this->max_ = value;
00031 this->max_at_ = this->samples_count_;
00032 this->sum_ = value;
00033 #if defined ACE_LACKS_LONGLONG_T
00034 this->sum2_ = value * ACE_U64_TO_U32 (value);
00035 #else /* ! ACE_LACKS_LONGLONG_T */
00036 this->sum2_ = value * value;
00037 #endif /* ! ACE_LACKS_LONGLONG_T */
00038 }
00039 else
00040 {
00041 if (this->min_ > value)
00042 {
00043 this->min_ = value;
00044 this->min_at_ = this->samples_count_;
00045 }
00046 if (this->max_ < value)
00047 {
00048 this->max_ = value;
00049 this->max_at_ = this->samples_count_;
00050 }
00051
00052 this->sum_ += value;
00053 #if defined ACE_LACKS_LONGLONG_T
00054 this->sum2_ += value * ACE_U64_TO_U32 (value);
00055 #else /* ! ACE_LACKS_LONGLONG_T */
00056 this->sum2_ += value * value;
00057 #endif /* ! ACE_LACKS_LONGLONG_T */
00058 }
00059 }
|
|
|
The number of samples received so far.
Definition at line 16 of file Basic_Stats.inl. References samples_count_. Referenced by ACE_Throughput_Stats::accumulate, ACE_Throughput_Stats::dump_results, dump_results, ACE_Throughput_Stats::dump_throughput, and ACE_Throughput_Stats::sample.
00017 {
00018 return this->samples_count_;
00019 }
|
|
|
The maximum value.
Definition at line 70 of file Basic_Stats.h. Referenced by accumulate, and sample. |
|
|
The number of the sample that had the maximum value.
Definition at line 73 of file Basic_Stats.h. Referenced by sample. |
|
|
The minimum value.
Definition at line 64 of file Basic_Stats.h. Referenced by accumulate, and sample. |
|
|
The number of the sample that had the minimum value.
Definition at line 67 of file Basic_Stats.h. Referenced by sample. |
|
|
The number of samples.
Definition at line 61 of file Basic_Stats.h. Referenced by accumulate, dump_results, sample, and samples_count. |
|
|
The sum of the square of all the values.
Definition at line 79 of file Basic_Stats.h. Referenced by accumulate, dump_results, and sample. |
|
|
The sum of all the values.
Definition at line 76 of file Basic_Stats.h. Referenced by accumulate, dump_results, and sample. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002