Motr  M0
Statistics Collector
Collaboration diagram for Statistics Collector:

Data Structures

struct  m0_net_test_stats
 

Macros

#define M0_NET_TEST_STATS_DEFINE(min, max, sum, sum_sqr, count)
 

Functions

void m0_net_test_stats_reset (struct m0_net_test_stats *stats)
 
bool m0_net_test_stats_invariant (const struct m0_net_test_stats *stats)
 
void m0_net_test_stats_add (struct m0_net_test_stats *stats, unsigned long value)
 
void m0_net_test_stats_add_stats (struct m0_net_test_stats *stats, const struct m0_net_test_stats *stats2)
 
unsigned long m0_net_test_stats_min (const struct m0_net_test_stats *stats)
 
unsigned long m0_net_test_stats_max (const struct m0_net_test_stats *stats)
 
m0_bcount_t m0_net_test_stats_serialize (enum m0_net_test_serialize_op op, struct m0_net_test_stats *stats, struct m0_bufvec *bv, m0_bcount_t bv_offset)
 
void m0_net_test_stats_time_add (struct m0_net_test_stats *stats, m0_time_t time)
 
m0_time_t m0_net_test_stats_time_min (struct m0_net_test_stats *stats)
 
m0_time_t m0_net_test_stats_time_max (struct m0_net_test_stats *stats)
 
double m0_net_test_stats_sum (const struct m0_net_test_stats *stats)
 
double m0_net_test_stats_avg (const struct m0_net_test_stats *stats)
 
double m0_net_test_stats_stddev (const struct m0_net_test_stats *stats)
 
m0_time_t m0_net_test_stats_time_sum (struct m0_net_test_stats *stats)
 
m0_time_t m0_net_test_stats_time_avg (struct m0_net_test_stats *stats)
 
m0_time_t m0_net_test_stats_time_stddev (struct m0_net_test_stats *stats)
 

Detailed Description

Todo:
Move to lib/stats.h

Arithmetic mean calculation:

\[ \overline{x} = \frac {1}{N} \sum\limits_{i=1}^N {x_i} \]

It is assumed that arithmetic mean = 0 if N == 0.

Sample standard deviation calculation:

\[ s = \sqrt {\frac {1}{N - 1} \sum\limits_{i=1}^N {(x_i - \overline{x})^2} } = \sqrt {\frac {1}{N - 1} (\sum\limits_{i=1}^N {x_i^2} + \sum\limits_{i=1}^N {\overline{x}^2} - 2 \sum\limits_{i=1}^N {x_i \overline{x}} )} = \sqrt {\frac {1}{N - 1} (\sum\limits_{i=1}^N {x_i^2} + N {\overline{x}^2} - 2 \overline{x} \sum\limits_{i=1}^N {x_i})} \]

We have $ N \overline{x} = \sum\limits_{i=1}^N {x_i} $, so

\[ s = \sqrt {\frac {1}{N - 1} (\sum\limits_{i=1}^N {x_i^2} + N {\overline{x}^2} - 2 \overline{x} \cdot N \overline{x} )} = \sqrt {\frac {1}{N - 1} (\sum\limits_{i=1}^N {x_i^2} - N {\overline{x}^2})} \]

It is assumed that sample standard deviation = 0 if N == 0 || N == 1.

Constraints:

See also
Motr Network Benchmark

Macro Definition Documentation

◆ M0_NET_TEST_STATS_DEFINE

#define M0_NET_TEST_STATS_DEFINE (   min,
  max,
  sum,
  sum_sqr,
  count 
)

Static initializer for m0_net_test_stats

Definition at line 105 of file stats.h.

Function Documentation

◆ m0_net_test_stats_add()

void m0_net_test_stats_add ( struct m0_net_test_stats stats,
unsigned long  value 
)

Add value to sample.

Precondition
m0_net_test_stats_invariant(stats)

Definition at line 69 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_add_stats()

void m0_net_test_stats_add_stats ( struct m0_net_test_stats stats,
const struct m0_net_test_stats stats2 
)

Merge two samples and write result to *stats. Subsequents calls to m0_net_test_stats_FUNC will be the same as if all values, which was added to the second sample (stats2), would be added to the first sample (stats). Result is stored in the first sample structure.

Precondition
m0_net_test_stats_invariant(stats)
m0_net_test_stats_invariant(stats2)

Definition at line 91 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_avg()

double m0_net_test_stats_avg ( const struct m0_net_test_stats stats)

Get sample average (arithmetic mean).

Precondition
m0_net_test_stats_invariant(stats)

Definition at line 50 of file stats_u.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_invariant()

bool m0_net_test_stats_invariant ( const struct m0_net_test_stats stats)

Invariant for m0_net_test_stats.

Definition at line 52 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_max()

unsigned long m0_net_test_stats_max ( const struct m0_net_test_stats stats)

Get the largest value from a given sample.

Precondition
m0_net_test_stats_invariant(stats)

Definition at line 117 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_min()

unsigned long m0_net_test_stats_min ( const struct m0_net_test_stats stats)

Get the smallest value from a given sample.

Precondition
m0_net_test_stats_invariant(stats)

Definition at line 110 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_reset()

void m0_net_test_stats_reset ( struct m0_net_test_stats stats)

Reset m0_net_test_stats structure. Set sample size and min/max/sum/sum_sqr to 0.

Postcondition
m0_net_test_stats_invariant(stats)

Definition at line 46 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_serialize()

m0_bcount_t m0_net_test_stats_serialize ( enum m0_net_test_serialize_op  op,
struct m0_net_test_stats stats,
struct m0_bufvec bv,
m0_bcount_t  bv_offset 
)

Serialize/deserialize m0_net_test_stats.

See also
m0_net_test_serialize().

Definition at line 135 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_stddev()

double m0_net_test_stats_stddev ( const struct m0_net_test_stats stats)

Get sample standard deviation.

Precondition
m0_net_test_stats_invariant(stats)

Definition at line 60 of file stats_u.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_sum()

double m0_net_test_stats_sum ( const struct m0_net_test_stats stats)

Get sum of all elements from sample.

Precondition
m0_net_test_stats_invariant(stats)

Definition at line 43 of file stats_u.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_time_add()

void m0_net_test_stats_time_add ( struct m0_net_test_stats stats,
m0_time_t  time 
)

The same as m0_net_test_stats_add(), but using m0_time_t as sample element. Next function can be used after this function to obtain m0_time_t results:

Definition at line 161 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_time_avg()

m0_time_t m0_net_test_stats_time_avg ( struct m0_net_test_stats stats)
See also
m0_net_test_stats_time_add()

Definition at line 96 of file stats_u.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_time_max()

m0_time_t m0_net_test_stats_time_max ( struct m0_net_test_stats stats)
See also
m0_net_test_stats_time_add()

Definition at line 171 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_time_min()

m0_time_t m0_net_test_stats_time_min ( struct m0_net_test_stats stats)
See also
m0_net_test_stats_time_add()

Definition at line 166 of file stats.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_time_stddev()

m0_time_t m0_net_test_stats_time_stddev ( struct m0_net_test_stats stats)
See also
m0_net_test_stats_time_add()

Definition at line 101 of file stats_u.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ m0_net_test_stats_time_sum()

m0_time_t m0_net_test_stats_time_sum ( struct m0_net_test_stats stats)
See also
m0_net_test_stats_time_add()

Definition at line 91 of file stats_u.c.

Here is the call graph for this function:
Here is the caller graph for this function: