Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Throughput_Stats.cpp
blob4a472d27c3d843a7f56751741691849fd5f2f04c
1 #include "ace/Throughput_Stats.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "ace/OS_NS_string.h"
5 #include "ace/High_Res_Timer.h"
6 #include "ace/Log_Category.h"
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 void
11 ACE_Throughput_Stats::sample (ACE_UINT64 throughput,
12 ACE_UINT64 latency)
14 this->ACE_Basic_Stats::sample (latency);
16 if (this->samples_count () == 1u)
18 this->throughput_last_ = throughput;
22 void
23 ACE_Throughput_Stats::accumulate (const ACE_Throughput_Stats &rhs)
25 if (rhs.samples_count () == 0u)
26 return;
28 this->ACE_Basic_Stats::accumulate (rhs);
30 if (this->samples_count () == 0u)
32 this->throughput_last_ = rhs.throughput_last_;
34 else if (this->throughput_last_ < rhs.throughput_last_)
36 this->throughput_last_ = rhs.throughput_last_;
40 void
41 ACE_Throughput_Stats::dump_results (const ACE_TCHAR* msg,
42 ACE_Basic_Stats::scale_factor_type sf)
44 if (this->samples_count () == 0u)
46 ACELIB_DEBUG ((LM_DEBUG,
47 ACE_TEXT ("%s : no data collected\n"), msg));
48 return;
51 this->ACE_Basic_Stats::dump_results (msg, sf);
53 ACE_Throughput_Stats::dump_throughput (msg, sf,
54 this->throughput_last_,
55 this->samples_count ());
58 void
59 ACE_Throughput_Stats::dump_throughput (const ACE_TCHAR *msg,
60 ACE_Basic_Stats::scale_factor_type sf,
61 ACE_UINT64 elapsed_time,
62 ACE_UINT32 samples_count)
64 #ifndef ACE_NLOGGING
65 double seconds =
66 static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER (elapsed_time / sf));
67 seconds /= ACE_HR_SCALE_CONVERSION;
69 double t_avg = 0.0;
70 if (seconds > 0.0)
72 t_avg = samples_count / seconds;
75 ACELIB_DEBUG ((LM_DEBUG,
76 ACE_TEXT ("%s throughput: %.2f (events/second)\n"),
77 msg, t_avg));
78 #else
79 ACE_UNUSED_ARG (msg);
80 ACE_UNUSED_ARG (sf);
81 ACE_UNUSED_ARG (elapsed_time);
82 ACE_UNUSED_ARG (samples_count);
83 #endif /* ACE_NLOGGING */
86 ACE_END_VERSIONED_NAMESPACE_DECL