00001
00002
00003 #include "ace/Basic_Stats.h"
00004 #include "ace/Log_Msg.h"
00005
00006 #if !defined (__ACE_INLINE__)
00007 #include "ace/Basic_Stats.inl"
00008 #endif
00009
00010 ACE_RCSID(ace,
00011 Basic_Stats,
00012 "$Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $")
00013
00014 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00015
00016 void
00017 ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs)
00018 {
00019 if (rhs.samples_count_ == 0)
00020 return;
00021
00022 if (this->samples_count_ == 0)
00023 {
00024 this->min_ = rhs.min_;
00025 this->min_at_ = rhs.min_at_;
00026
00027 this->max_ = rhs.max_;
00028 this->max_at_ = rhs.max_at_;
00029 }
00030 else
00031 {
00032 if (this->min_ > rhs.min_)
00033 {
00034 this->min_ = rhs.min_;
00035 this->min_at_ = rhs.min_at_;
00036 }
00037 if (this->max_ < rhs.max_)
00038 {
00039 this->max_ = rhs.max_;
00040 this->max_at_ = rhs.max_at_;
00041 }
00042 }
00043
00044 this->samples_count_ += rhs.samples_count_;
00045 this->sum_ += rhs.sum_;
00046 }
00047
00048 void
00049 ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, ACE_UINT32 sf) const
00050 {
00051 #ifndef ACE_NLOGGING
00052 if (this->samples_count () == 0u)
00053 {
00054 ACE_DEBUG ((LM_DEBUG,
00055 ACE_TEXT ("%s : no data collected\n"), msg));
00056 return;
00057 }
00058
00059 ACE_UINT64 avg = this->sum_ / this->samples_count_;
00060
00061 ACE_UINT64 l_min = this->min_ / sf;
00062 ACE_UINT64 l_max = this->max_ / sf;
00063 ACE_UINT64 l_avg = avg / sf;
00064
00065 ACE_DEBUG ((LM_DEBUG,
00066 ACE_TEXT ("%s latency : %Q[%d]/%Q/%Q[%d] (min/avg/max)\n"),
00067 msg,
00068 l_min, this->min_at_,
00069 l_avg,
00070 l_max, this->max_at_));
00071
00072 #else
00073 ACE_UNUSED_ARG (msg);
00074 ACE_UNUSED_ARG (sf);
00075 #endif
00076 }
00077
00078 ACE_END_VERSIONED_NAMESPACE_DECL