Public Member Functions | Public Attributes

ACE_Basic_Stats Class Reference

Collect basic stats about a series of samples. More...

#include <Basic_Stats.h>

Inheritance diagram for ACE_Basic_Stats:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 ACE_Basic_Stats (void)
 Constructor.
ACE_UINT32 samples_count (void) const
 The number of samples received so far.
void sample (ACE_UINT64 value)
 Record one sample.
void accumulate (const ACE_Basic_Stats &rhs)
 Update the values to reflect the stats in rhs.
void dump_results (const ACE_TCHAR *msg, ACE_UINT32 scale_factor) const
 Dump all the samples.

Public Attributes

ACE_UINT32 samples_count_
 The number of samples.
ACE_UINT64 min_
 The minimum value.
ACE_UINT32 min_at_
 The number of the sample that had the minimum value.
ACE_UINT64 max_
 The maximum value.
ACE_UINT32 max_at_
 The number of the sample that had the maximum value.
ACE_UINT64 sum_
 The sum of all the values.

Detailed Description

Collect basic stats about a series of samples.

Compute the average and standard deviation (aka jitter) for an arbitrary number of samples, using constant space. Normally used for latency statistics.

Definition at line 32 of file Basic_Stats.h.


Constructor & Destructor Documentation

ACE_Basic_Stats::ACE_Basic_Stats ( void   )  [inline]

Constructor.

The number of samples is pre-allocated, and cannot changes once the class is initialized.

Definition at line 8 of file Basic_Stats.inl.

  : samples_count_ (0)
  , min_ (0)
  , min_at_ (0)
  , max_ (0)
  , max_at_ (0)
  , sum_ (0)
{
}


Member Function Documentation

void ACE_Basic_Stats::accumulate ( const ACE_Basic_Stats rhs  ) 

Update the values to reflect the stats in rhs.

void ACE_Basic_Stats::dump_results ( const ACE_TCHAR msg,
ACE_UINT32  scale_factor 
) const

Dump all the samples.

Prints out the results, using msg as a prefix for each message and scaling all the numbers by scale_factor. The latter is useful because high resolution timer samples are acquired in clock ticks, but often presented in microseconds.

Definition at line 49 of file Basic_Stats.cpp.

{
#ifndef ACE_NLOGGING
  if (this->samples_count () == 0u)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("%s : no data collected\n"), msg));
      return;
    }

  ACE_UINT64 avg = this->sum_ / this->samples_count_;

  ACE_UINT64 l_min = this->min_ / sf;
  ACE_UINT64 l_max = this->max_ / sf;
  ACE_UINT64 l_avg = avg / sf;

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("%s latency   : %Q[%d]/%Q/%Q[%d] (min/avg/max)\n"),
              msg,
              l_min, this->min_at_,
              l_avg,
              l_max, this->max_at_));

#else
  ACE_UNUSED_ARG (msg);
  ACE_UNUSED_ARG (sf);
#endif /* ACE_NLOGGING */
}

void ACE_Basic_Stats::sample ( ACE_UINT64  value  )  [inline]

Record one sample.

Definition at line 25 of file Basic_Stats.inl.

{
  ++this->samples_count_;

  if (this->samples_count_ == 1u)
    {
      this->min_ = value;
      this->min_at_ = this->samples_count_;
      this->max_ = value;
      this->max_at_ = this->samples_count_;
    }
  else
    {
      if (this->min_ > value)
        {
          this->min_ = value;
          this->min_at_ = this->samples_count_;
        }
      if (this->max_ < value)
        {
          this->max_ = value;
          this->max_at_ = this->samples_count_;
        }
    }

  this->sum_ += value;
}

ACE_UINT32 ACE_Basic_Stats::samples_count ( void   )  const [inline]

The number of samples received so far.

Definition at line 19 of file Basic_Stats.inl.

{
  return this->samples_count_;
}


Member Data Documentation

The maximum value.

Definition at line 71 of file Basic_Stats.h.

The number of the sample that had the maximum value.

Definition at line 74 of file Basic_Stats.h.

The minimum value.

Definition at line 65 of file Basic_Stats.h.

The number of the sample that had the minimum value.

Definition at line 68 of file Basic_Stats.h.

The number of samples.

Definition at line 62 of file Basic_Stats.h.

The sum of all the values.

Definition at line 77 of file Basic_Stats.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines