1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// $Id$
#include "ace/Throughput_Stats.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_string.h"
#include "ace/High_Res_Timer.h"
#include "ace/Log_Category.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_Throughput_Stats::ACE_Throughput_Stats (void)
: ACE_Basic_Stats ()
, throughput_last_ (0)
{
}
void
ACE_Throughput_Stats::sample (ACE_UINT64 throughput,
ACE_UINT64 latency)
{
this->ACE_Basic_Stats::sample (latency);
if (this->samples_count () == 1u)
{
this->throughput_last_ = throughput;
}
}
void
ACE_Throughput_Stats::accumulate (const ACE_Throughput_Stats &rhs)
{
if (rhs.samples_count () == 0u)
return;
this->ACE_Basic_Stats::accumulate (rhs);
if (this->samples_count () == 0u)
{
this->throughput_last_ = rhs.throughput_last_;
}
else if (this->throughput_last_ < rhs.throughput_last_)
{
this->throughput_last_ = rhs.throughput_last_;
}
}
void
ACE_Throughput_Stats::dump_results (const ACE_TCHAR* msg,
ACE_Basic_Stats::scale_factor_type sf)
{
if (this->samples_count () == 0u)
{
ACELIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("%s : no data collected\n"), msg));
return;
}
this->ACE_Basic_Stats::dump_results (msg, sf);
ACE_Throughput_Stats::dump_throughput (msg, sf,
this->throughput_last_,
this->samples_count ());
}
void
ACE_Throughput_Stats::dump_throughput (const ACE_TCHAR *msg,
ACE_Basic_Stats::scale_factor_type sf,
ACE_UINT64 elapsed_time,
ACE_UINT32 samples_count)
{
#ifndef ACE_NLOGGING
double seconds =
static_cast<double> (ACE_UINT64_DBLCAST_ADAPTER (elapsed_time / sf));
seconds /= ACE_HR_SCALE_CONVERSION;
double t_avg = 0.0;
if (seconds > 0.0)
{
t_avg = samples_count / seconds;
}
ACELIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("%s throughput: %.2f (events/second)\n"),
msg, t_avg));
#else
ACE_UNUSED_ARG (msg);
ACE_UNUSED_ARG (sf);
ACE_UNUSED_ARG (elapsed_time);
ACE_UNUSED_ARG (samples_count);
#endif /* ACE_NLOGGING */
}
ACE_END_VERSIONED_NAMESPACE_DECL
|