C++ Reference: stats

This documentation is automatically generated.

Helper classes to track statistics of a program component.

Usage example:
 // Suppose you have a class that contains a factorization of a matrix B and
 // a Solve() function to solve the linear system B.x = a.
 // You will hold your stats in a Stats stats_ class member:
 struct Stats : public StatsGroup {
   Stats() : StatsGroup("BasisFactorization"),
       solve_time("solve_time", this),
       input_vector_density("input_vector_density", this),
       estimated_accuracy("estimated_accuracy", this) {}
   TimeDistribution solve_time;
   RatioDistribution input_vector_density;
   // Values of a few components of B.x - a, updated on each solve.
   DoubleDistribution estimated_accuracy;
 }
 // You then add a few lines to your Solve() function:
 void Solve() {
   stats_.solve_time.StartTimer();
   stats_.input_vector_density.Add(ComputeDensity());
   ...  // Do the work.
   stats_.estimated_accuracy.Add(EstimateAccuracy());
   stats_.solve_time.StopTimerAndAddElapsedTime();
 }
 // Now, calling stats_.StatString() will give you a summary of your stats:
 BasisFactorization {
   solve_time           : num [min, max] average std_deviation total
   input_vector_density : num [min, max] average std_deviation
   estimated_accuracy   : num [min, max] average std_deviation
 }
For measuring time, another alternative is to use the SCOPED_TIME_STAT macro. In our example above, you don't need to define the solve_time distribution and you can just do:
 void Solve() {
   SCOPED_TIME_STAT(&stats_);
   ...
 }
This automatically adds a TimeDistribution with name "Solve" to stats_ and times your function calls!

IMPORTANT: The SCOPED_TIME_STAT() macro only does something if OR_STATS is defined, so you need to build your code with blaze build --copt='-DOR_STATS'. The idea is that by default the instrumentation is off. You can also use the macro IF_STATS_ENABLED() that does nothing if OR_STATS is not defined or just translates to its argument otherwise.

Classes

DisabledScopedInstructionCounter
DisabledScopedTimeDistributionUpdater
DistributionStat
DoubleDistribution
EnabledScopedInstructionCounter
EnabledScopedTimeDistributionUpdater
IntegerDistribution
RatioDistribution
Stat
StatsGroup
TimeDistribution

Send feedback about...