Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Sample_History Class Reference

Save multiple samples in an array. More...

#include <Sample_History.h>

List of all members.

Public Methods

 ACE_Sample_History (size_t max_samples)
 Constructor. More...

 ~ACE_Sample_History (void)
 Destructor. More...

int sample (ACE_UINT64 value)
 Record one sample. More...

size_t max_samples (void) const
 Returns the maximum number of samples. More...

size_t sample_count (void) const
 Returns the current number of samples. More...

void dump_samples (const ACE_TCHAR *msg, ACE_UINT32 scale_factor) const
 Dump all the samples. More...

void collect_basic_stats (ACE_Basic_Stats &) const
 Collect the summary for all the samples. More...

ACE_UINT64 get_sample (size_t i) const
 Get a sample. More...


Private Attributes

size_t max_samples_
 The maximum number of samples. More...

size_t sample_count_
 The current number of samples. More...

ACE_UINT64samples_
 The samples. More...


Detailed Description

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 31 of file Sample_History.h.


Constructor & Destructor Documentation

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 15 of file Sample_History.cpp.

References ACE_NEW, and ACE_UINT64.

00016   : max_samples_ (max_samples)
00017   , sample_count_ (0)
00018 {
00019   ACE_NEW(this->samples_, ACE_UINT64[this->max_samples_]);
00020 }

ACE_Sample_History::~ACE_Sample_History void   
 

Destructor.

Definition at line 22 of file Sample_History.cpp.

References samples_.

00023 {
00024   delete[] this->samples_;
00025 }


Member Function Documentation

void ACE_Sample_History::collect_basic_stats ACE_Basic_Stats   const
 

Collect the summary for all the samples.

Definition at line 52 of file Sample_History.cpp.

References ACE_Basic_Stats::sample, and sample_count_.

00053 {
00054   for (size_t i = 0; i != this->sample_count_; ++i)
00055     {
00056       stats.sample (this->samples_[i]);
00057     }
00058 }

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 40 of file Sample_History.cpp.

References ACE_CU64_TO_CU32, ACE_DEBUG, ACE_LIB_TEXT, ACE_TCHAR, ACE_UINT64, LM_DEBUG, sample_count_, and samples_.

00042 {
00043   for (size_t i = 0; i != this->sample_count_; ++i)
00044     {
00045       ACE_UINT64 x = this->samples_[i] / scale_factor;
00046       ACE_UINT32 val = ACE_CU64_TO_CU32 (x);
00047       ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT("%s: %d %u\n"), msg, i, val));
00048     }
00049 }

ACE_INLINE ACE_UINT64 ACE_Sample_History::get_sample size_t    i const
 

Get a sample.

Definition at line 14 of file Sample_History.inl.

References sample_count_, and samples_.

00015 {
00016   if (this->sample_count_ <= i)
00017     return 0;
00018 
00019   return this->samples_[i];
00020 }

size_t ACE_Sample_History::max_samples void    const
 

Returns the maximum number of samples.

Definition at line 28 of file Sample_History.cpp.

References max_samples_.

00029 {
00030   return this->max_samples_;
00031 }

ACE_INLINE 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 4 of file Sample_History.inl.

References ACE_UINT64, max_samples_, sample_count_, and samples_.

00005 {
00006   if (this->sample_count_ >= this->max_samples_)
00007     return -1;
00008 
00009   this->samples_[this->sample_count_++] = value;
00010   return 0;
00011 }

size_t ACE_Sample_History::sample_count void    const
 

Returns the current number of samples.

Definition at line 34 of file Sample_History.cpp.

References sample_count_.

00035 {
00036   return this->sample_count_;
00037 }


Member Data Documentation

size_t ACE_Sample_History::max_samples_ [private]
 

The maximum number of samples.

Definition at line 72 of file Sample_History.h.

Referenced by max_samples, and sample.

size_t ACE_Sample_History::sample_count_ [private]
 

The current number of samples.

Definition at line 75 of file Sample_History.h.

Referenced by collect_basic_stats, dump_samples, get_sample, sample, and sample_count.

ACE_UINT64* ACE_Sample_History::samples_ [private]
 

The samples.

Definition at line 78 of file Sample_History.h.

Referenced by dump_samples, get_sample, sample, and ~ACE_Sample_History.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:55:30 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002