diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-10-27 22:36:12 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-10-27 22:36:12 +0000 |
commit | dfe45b5d06763fdc6a51932192fcd7c43b8fbb9e (patch) | |
tree | 2b76ce3e3dd87fba4c4c9d931462aef30063e0bb /ace/Basic_Stats.cpp | |
parent | 85f6f6c076d8ed29cda024d9c6255c902220d840 (diff) | |
download | ATCD-dfe45b5d06763fdc6a51932192fcd7c43b8fbb9e.tar.gz |
ChangeLogTag:Fri Oct 27 15:02:56 2000 Carlos O'Ryan <coryan@uci.edu>
Diffstat (limited to 'ace/Basic_Stats.cpp')
-rw-r--r-- | ace/Basic_Stats.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/ace/Basic_Stats.cpp b/ace/Basic_Stats.cpp new file mode 100644 index 00000000000..c363713f3f3 --- /dev/null +++ b/ace/Basic_Stats.cpp @@ -0,0 +1,66 @@ +// $Id$ + +#include "ace/Basic_Stats.h" +#include "ace/Log_Msg.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Basic_Stats.inl" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(ace, Basic_Stats, "$Id$") + +void +ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs) +{ + if (rhs.samples_count_ == 0) + return; + + if (this->samples_count_ == 0) + { + this->samples_count_ = rhs.samples_count_; + + this->min_ = rhs.min_; + this->max_ = rhs.max_; + this->sum_ = rhs.sum_; + this->sum2_ = rhs.sum2_; + + return; + } + this->samples_count_ += rhs.samples_count_; + + if (this->min_ > rhs.min_) + this->min_ = rhs.min_; + if (this->max_ < rhs.max_) + this->max_ = rhs.max_; + + this->sum_ += rhs.sum_; + this->sum2_ += rhs.sum2_; +} + +void +ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, + ACE_UINT32 sf) const +{ + if (this->samples_count () == 0u) + { + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("%s : no data collected\n"), msg)); + return; + } + + ACE_UINT64 avg = this->sum_ / this->samples_count_; + ACE_UINT64 dev = this->sum2_ / this->samples_count_ - avg * avg; + + double l_min = ACE_CU64_TO_CU32 (this->min_) / sf; + double l_max = ACE_CU64_TO_CU32 (this->max_) / sf; + double l_avg = ACE_CU64_TO_CU32 (avg) / sf; + double l_dev = ACE_CU64_TO_CU32 (dev) / (sf * sf); + + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("%s latency : %.2f[%d]/%.2f/%.2f[%d]/%.2f (min/avg/max/var^2)\n"), + msg, + l_min, this->min_at_, + l_avg, + l_max, this->max_at_, + l_dev)); +} |