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 "Basic_Stats.cpp,v 4.6 2005/10/28 16:14:51 ossama Exp")
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,
00050 ACE_UINT32 sf) const
00051 {
00052 #ifndef ACE_NLOGGING
00053 if (this->samples_count () == 0u)
00054 {
00055 ACE_DEBUG ((LM_DEBUG,
00056 ACE_LIB_TEXT ("%s : no data collected\n"), msg));
00057 return;
00058 }
00059
00060 ACE_UINT64 avg = this->sum_ / this->samples_count_;
00061
00062 ACE_UINT64 l_min = this->min_ / sf;
00063 ACE_UINT64 l_max = this->max_ / sf;
00064 ACE_UINT64 l_avg = avg / sf;
00065
00066 ACE_DEBUG ((LM_DEBUG,
00067 ACE_LIB_TEXT ("%s latency : %Q[%d]/%Q/%Q[%d] (min/avg/max)\n"),
00068 msg,
00069 l_min, this->min_at_,
00070 l_avg,
00071 l_max, this->max_at_));
00072
00073 #endif
00074 }
00075
00076 ACE_END_VERSIONED_NAMESPACE_DECL