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
11 ACE_Throughput_Stats::sample (ACE_UINT64 throughput
,
14 this->ACE_Basic_Stats::sample (latency
);
16 if (this->samples_count () == 1u)
18 this->throughput_last_
= throughput
;
23 ACE_Throughput_Stats::accumulate (const ACE_Throughput_Stats
&rhs
)
25 if (rhs
.samples_count () == 0u)
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_
;
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
));
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 ());
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
)
66 static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER (elapsed_time
/ sf
));
67 seconds
/= ACE_HR_SCALE_CONVERSION
;
72 t_avg
= samples_count
/ seconds
;
75 ACELIB_DEBUG ((LM_DEBUG
,
76 ACE_TEXT ("%s throughput: %.2f (events/second)\n"),
81 ACE_UNUSED_ARG (elapsed_time
);
82 ACE_UNUSED_ARG (samples_count
);
83 #endif /* ACE_NLOGGING */
86 ACE_END_VERSIONED_NAMESPACE_DECL