Save multiple samples in an array. More...
#include <Sample_History.h>
Public Member Functions | |
ACE_Sample_History (size_t max_samples) | |
Constructor. | |
~ACE_Sample_History (void) | |
Destructor. | |
int | sample (ACE_UINT64 value) |
Record one sample. | |
size_t | max_samples (void) const |
Returns the maximum number of samples. | |
size_t | sample_count (void) const |
Returns the current number of samples. | |
void | dump_samples (const ACE_TCHAR *msg, ACE_UINT32 scale_factor) const |
Dump all the samples. | |
void | collect_basic_stats (ACE_Basic_Stats &) const |
Collect the summary for all the samples. | |
ACE_UINT64 | get_sample (size_t i) const |
Get a sample. | |
Private Attributes | |
size_t | max_samples_ |
The maximum number of samples. | |
size_t | sample_count_ |
The current number of samples. | |
ACE_UINT64 * | samples_ |
The samples. |
Save multiple samples in an array.
Save multiple samples (usually latency numbers), into an array, and later print them in several formats.
Definition at line 34 of file Sample_History.h.
ACE_Sample_History::ACE_Sample_History | ( | size_t | max_samples | ) |
Constructor.
The number of samples is pre-allocated, and cannot changes once the class is initialized.
Definition at line 18 of file Sample_History.cpp.
: max_samples_ (max_samples) , sample_count_ (0) { ACE_NEW(this->samples_, ACE_UINT64[this->max_samples_]); }
ACE_Sample_History::~ACE_Sample_History | ( | void | ) |
void ACE_Sample_History::collect_basic_stats | ( | ACE_Basic_Stats & | stats | ) | const |
Collect the summary for all the samples.
Definition at line 65 of file Sample_History.cpp.
{ for (size_t i = 0; i != this->sample_count_; ++i) { stats.sample (this->samples_[i]); } }
void ACE_Sample_History::dump_samples | ( | const ACE_TCHAR * | msg, | |
ACE_UINT32 | scale_factor | |||
) | const |
Dump all the samples.
Prints out all the samples, using msg as a prefix for each message.
Definition at line 43 of file Sample_History.cpp.
{ #ifndef ACE_NLOGGING for (size_t i = 0; i != this->sample_count_; ++i) { ACE_UINT64 const val = this->samples_[i] / scale_factor; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%s: ") ACE_SIZE_T_FORMAT_SPECIFIER ACE_TEXT ("\t%Q\n"), msg, i, val)); } #else ACE_UNUSED_ARG (msg); ACE_UNUSED_ARG (scale_factor); #endif /* ACE_NLOGGING */ }
ACE_UINT64 ACE_Sample_History::get_sample | ( | size_t | i | ) | const |
Get a sample.
Definition at line 18 of file Sample_History.inl.
{ if (this->sample_count_ <= i) return 0; return this->samples_[i]; }
size_t ACE_Sample_History::max_samples | ( | void | ) | const |
Returns the maximum number of samples.
Definition at line 31 of file Sample_History.cpp.
{ return this->max_samples_; }
int ACE_Sample_History::sample | ( | ACE_UINT64 | value | ) |
Record one sample.
Return 0 on success, -1 if the sample could not be stored
Definition at line 8 of file Sample_History.inl.
{ if (this->sample_count_ >= this->max_samples_) return -1; this->samples_[this->sample_count_++] = value; return 0; }
size_t ACE_Sample_History::sample_count | ( | void | ) | const |
Returns the current number of samples.
Definition at line 37 of file Sample_History.cpp.
{ return this->sample_count_; }
size_t ACE_Sample_History::max_samples_ [private] |
The maximum number of samples.
Definition at line 75 of file Sample_History.h.
size_t ACE_Sample_History::sample_count_ [private] |
The current number of samples.
Definition at line 78 of file Sample_History.h.
ACE_UINT64* ACE_Sample_History::samples_ [private] |
The samples.
Definition at line 81 of file Sample_History.h.