Restore build on FreeBSD.
[getmangos.git] / dep / ACE_wrappers / ace / Basic_Stats.cpp
blobfe678333d892903a663538c0cce3942cc7720ac7
1 // $Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/Basic_Stats.h"
4 #include "ace/Log_Msg.h"
6 #if !defined (__ACE_INLINE__)
7 #include "ace/Basic_Stats.inl"
8 #endif /* __ACE_INLINE__ */
10 ACE_RCSID(ace,
11 Basic_Stats,
12 "$Id: Basic_Stats.cpp 80826 2008-03-04 14:51:23Z wotte $")
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 void
17 ACE_Basic_Stats::accumulate (const ACE_Basic_Stats &rhs)
19 if (rhs.samples_count_ == 0)
20 return;
22 if (this->samples_count_ == 0)
24 this->min_ = rhs.min_;
25 this->min_at_ = rhs.min_at_;
27 this->max_ = rhs.max_;
28 this->max_at_ = rhs.max_at_;
30 else
32 if (this->min_ > rhs.min_)
34 this->min_ = rhs.min_;
35 this->min_at_ = rhs.min_at_;
37 if (this->max_ < rhs.max_)
39 this->max_ = rhs.max_;
40 this->max_at_ = rhs.max_at_;
44 this->samples_count_ += rhs.samples_count_;
45 this->sum_ += rhs.sum_;
48 void
49 ACE_Basic_Stats::dump_results (const ACE_TCHAR *msg, ACE_UINT32 sf) const
51 #ifndef ACE_NLOGGING
52 if (this->samples_count () == 0u)
54 ACE_DEBUG ((LM_DEBUG,
55 ACE_TEXT ("%s : no data collected\n"), msg));
56 return;
59 ACE_UINT64 avg = this->sum_ / this->samples_count_;
61 ACE_UINT64 l_min = this->min_ / sf;
62 ACE_UINT64 l_max = this->max_ / sf;
63 ACE_UINT64 l_avg = avg / sf;
65 ACE_DEBUG ((LM_DEBUG,
66 ACE_TEXT ("%s latency : %Q[%d]/%Q/%Q[%d] (min/avg/max)\n"),
67 msg,
68 l_min, this->min_at_,
69 l_avg,
70 l_max, this->max_at_));
72 #else
73 ACE_UNUSED_ARG (msg);
74 ACE_UNUSED_ARG (sf);
75 #endif /* ACE_NLOGGING */
78 ACE_END_VERSIONED_NAMESPACE_DECL