#include <StatHist.h>

Inheritance diagram for StatHist:
Collaboration diagram for StatHist:

Public Types

typedef uint64_t bins_type

Public Member Functions

 StatHist ()
 StatHist (const StatHist &)
 ~StatHist ()
StatHistoperator= (const StatHist &)
void clear ()
double deltaPctile (const StatHist &B, double pctile) const
double val (unsigned int bin) const
void count (double val)
void dump (StoreEntry *sentry, StatHistBinDumper *bd) const
void logInit (unsigned int capacity, double min, double max)
void enumInit (unsigned int last_enum)
StatHistoperator+= (const StatHist &B)

Protected Member Functions

void init (unsigned int capacity, hbase_f *val_in, hbase_f *val_out, double min, double max)
unsigned int findBin (double v)

Protected Attributes

 the histogram counters More...
unsigned int capacity_
double min_
 minimum value to be stored, corresponding to the first bin More...
double max_
 value of the maximum counter in the histogram More...
double scale_
 scaling factor when looking for a bin More...

Detailed Description

Generic histogram class

see important comments on hbase_f restrictions in StatHist.cc

Definition at line 25 of file StatHist.h.

Member Typedef Documentation

typedef uint64_t StatHist::bins_type

Definition at line 39 of file StatHist.h.

Constructor & Destructor Documentation

StatHist::StatHist ( )
the default constructor doesn't fully initialize. you have to call one of the *init functions to specialize the histogram

merge functionality from the *init functions to the constructor and drop these

specialize the class in a small hierarchy so that all relevant initializations are done at build-time

Definition at line 146 of file StatHist.h.

StatHist::StatHist ( const StatHist src)

Definition at line 41 of file StatHist.cc.

References bins, capacity_, NULL, and xcalloc.

StatHist::~StatHist ( )

Definition at line 39 of file StatHist.h.

References clear().

Member Function Documentation

void StatHist::clear ( )

clear the contents of the histograms

remove: this function has been replaced in its purpose by the destructor

Definition at line 152 of file StatHist.h.

References bins, capacity_, NULL, and xfree.

Referenced by statCountersClean(), and ~StatHist().

double StatHist::deltaPctile ( const StatHist B,
double  pctile 
) const

Calculate the percentile for value pctile for the difference between this and the supplied histogram.

Definition at line 105 of file StatHist.cc.

References a, assert, bins, capacity_, D, i, int, s1, val(), xcalloc, and xfree.

Referenced by statHistDeltaPctile().

void StatHist::dump ( StoreEntry sentry,
StatHistBinDumper bd 
) const

iterate the supplied bd function over the histogram values

Definition at line 173 of file StatHist.cc.

References assert, bins, capacity_, i, min_, statHistBinDumper, and val().

Referenced by commIncomingStats(), SBufStatsAction::dump(), httpHeaderStatDump(), and statCountersHistograms().

void StatHist::enumInit ( unsigned int  last_enum)

initialize the histogram to count occurrences in an enum-represented set

Definition at line 237 of file StatHist.cc.

References init(), and Math::Null.

Referenced by HttpHeaderStat::HttpHeaderStat(), statCountersInitSpecial(), testStatHist::testStatHistBaseAssignment(), and testStatHist::testStatHistBaseEquality().

unsigned int StatHist::findBin ( double  v)

find what entry in the histogram corresponds to v, by applying the preset input transformation function

Definition at line 66 of file StatHist.cc.

References capacity_, min_, scale_, and val_in.

Referenced by count(), and InspectingStatHist::counter().

void StatHist::init ( unsigned int  capacity,
hbase_f val_in,
hbase_f val_out,
double  min,
double  max 

low-level initialize function. called by *Init high-level functions

Important restrictions on val_in and val_out functions:
  • val_in: ascending, defined on [0, oo), val_in(0) == 0;
  • val_out: x == val_out(val_in(x)) where val_in(x) is defined

In practice, the requirements are less strict, but then it gets hard to define them without math notation. val_in is applied after offseting the value but before scaling See log and linear based histograms for examples

Definition at line 28 of file StatHist.cc.

References assert, bins, capacity_, max_, min_, scale_, val_in, val_out, and xcalloc.

Referenced by enumInit(), and logInit().

void StatHist::logInit ( unsigned int  capacity,
double  min,
double  max 

Initialize the Histogram using a logarithmic values distribution

Definition at line 223 of file StatHist.cc.

References Math::Exp, init(), and Math::Log.

Referenced by newStatHist(), statCountersInitSpecial(), testStatHist::testStatHistLog(), and testStatHist::testStatHistSum().

StatHist & StatHist::operator+= ( const StatHist B)

Import values from another histogram

: the two histograms MUST have the same capicity, min and max or an exception will be raised

Definition at line 189 of file StatHist.cc.

References B, bins, capacity_, i, max_, min_, Must, and NULL.

StatHist & StatHist::operator= ( const StatHist src)

Definition at line 126 of file StatHist.h.

References bins, capacity_, max_, min_, NULL, scale_, val_in, val_out, xcalloc, and xfree.

double StatHist::val ( unsigned int  bin) const

obtain the output-transformed value from the specified bin

Definition at line 87 of file StatHist.cc.

References min_, scale_, and val_out.

Referenced by deltaPctile(), and dump().

Member Data Documentation

unsigned int StatHist::capacity_
double StatHist::max_

Definition at line 112 of file StatHist.h.

Referenced by init(), operator+=(), operator=(), and InspectingStatHist::operator==().

double StatHist::min_

Definition at line 109 of file StatHist.h.

Referenced by dump(), findBin(), init(), operator+=(), operator=(), InspectingStatHist::operator==(), and val().

double StatHist::scale_

Definition at line 115 of file StatHist.h.

Referenced by findBin(), init(), operator=(), InspectingStatHist::operator==(), and val().

hbase_f* StatHist::val_in

Definition at line 116 of file StatHist.h.

Referenced by findBin(), init(), operator=(), and InspectingStatHist::operator==().

hbase_f* StatHist::val_out

Definition at line 117 of file StatHist.h.

Referenced by init(), operator=(), InspectingStatHist::operator==(), and val().

The documentation for this class was generated from the following files:






Web Site Translations