Motr  M0
stats.c File Reference
#include <limits.h>
#include "lib/misc.h"
#include "ut/ut.h"
#include "motr/magic.h"
#include "net/test/stats.h"
Include dependency graph for stats.c:

Go to the source code of this file.

Data Structures

struct  stats_expected
 

Macros

#define STATS_SAMPLE(sample_name)   static unsigned long sample_name ## _sample[]
 
#define STATS__EXPECTED(sample_name, count, min, max, sum, avg, stddev)
 
#define STATS_EXPECTED   STATS__EXPECTED
 
#define STATS_SAMPLE_ADD(stats_name, sample_name)
 
#define STATS_CHECK(stats_name, sample_name)   sample_check(stats_name, &sample_name ## _expected)
 
#define STATS_ADD_CHECK(stats_name, sample_name)
 

Enumerations

enum  {
  STATS_ONE_MILLION = 1000000, STATS_BUF_LEN = 0x100, STATS_BUF_OFFSET = 42, TIMESTAMP_BUF_LEN = 0x100,
  TIMESTAMP_SEQ = 123456
}
 

Functions

static bool is_in_eps_neighborhood (double a, double b)
 
static void sample_check (struct m0_net_test_stats *stats, struct stats_expected *expected)
 
static void stats_serialize_ut (struct m0_net_test_stats *stats)
 
static void add_one_by_one (struct m0_net_test_stats *stats, unsigned long *arr, unsigned long arr_len)
 
 STATS_SAMPLE (one_value)
 
 STATS_EXPECTED (one_value, 1, 1, 1, 1., 1., 0.)
 
 STATS_SAMPLE (five_values)
 
 STATS_EXPECTED (five_values, 5, 1, 5, 15., 3., 1.58113883)
 
 STATS_EXPECTED (zero_values, 0, 0, 0, 0., 0., 0.)
 
 STATS_EXPECTED (million_values, STATS_ONE_MILLION, ULONG_MAX, ULONG_MAX, 1. *ULONG_MAX *STATS_ONE_MILLION, ULONG_MAX, 0.)
 
 STATS_EXPECTED (one_plus_five_values, 6, 1, 5, 16., 16./6, 1.632993161)
 
static void stats_time_ut (void)
 
void m0_net_test_stats_ut (void)
 
void m0_net_test_timestamp_ut (void)
 

Macro Definition Documentation

◆ STATS__EXPECTED

#define STATS__EXPECTED (   sample_name,
  count,
  min,
  max,
  sum,
  avg,
  stddev 
)
Value:
static struct stats_expected sample_name ## _expected = { \
.se_count = (count), \
.se_min = (min), \
.se_max = (max), \
.se_sum = (sum), \
.se_avg = (avg), \
.se_stddev = (stddev), \
}
static int sum
Definition: rwlock.c:53
static m0_bcount_t count
Definition: xcode.c:167
unsigned long se_count
Definition: stats.c:46
static long long max(long long a, long long b)
Definition: crate.c:196
double se_stddev
Definition: stats.c:52
static long long min(long long a, long long b)
Definition: crate.c:191
unsigned long se_min
Definition: stats.c:47
double se_sum
Definition: stats.c:50

Definition at line 148 of file stats.c.

◆ STATS_ADD_CHECK

#define STATS_ADD_CHECK (   stats_name,
  sample_name 
)
Value:
do { \
STATS_SAMPLE_ADD(stats_name, sample_name); \
STATS_CHECK(stats_name, sample_name); \
} while (0)

Definition at line 174 of file stats.c.

◆ STATS_CHECK

#define STATS_CHECK (   stats_name,
  sample_name 
)    sample_check(stats_name, &sample_name ## _expected)

Definition at line 171 of file stats.c.

◆ STATS_EXPECTED

#define STATS_EXPECTED   STATS__EXPECTED

Definition at line 159 of file stats.c.

◆ STATS_SAMPLE

#define STATS_SAMPLE (   sample_name)    static unsigned long sample_name ## _sample[]

Definition at line 145 of file stats.c.

◆ STATS_SAMPLE_ADD

#define STATS_SAMPLE_ADD (   stats_name,
  sample_name 
)
Value:
do { \
add_one_by_one(stats_name, sample_name ## _sample, \
ARRAY_SIZE(sample_name ## _sample)); \
} while (0)
#define ARRAY_SIZE(a)
Definition: misc.h:45

Definition at line 165 of file stats.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Todo:
create lib/limits.h
Enumerator
STATS_ONE_MILLION 
STATS_BUF_LEN 
STATS_BUF_OFFSET 
TIMESTAMP_BUF_LEN 
TIMESTAMP_SEQ 

Definition at line 37 of file stats.c.

Function Documentation

◆ add_one_by_one()

static void add_one_by_one ( struct m0_net_test_stats stats,
unsigned long *  arr,
unsigned long  arr_len 
)
static

Definition at line 132 of file stats.c.

Here is the call graph for this function:

◆ is_in_eps_neighborhood()

static bool is_in_eps_neighborhood ( double  a,
double  b 
)
static

Definition at line 61 of file stats.c.

Here is the caller graph for this function:

◆ m0_net_test_stats_ut()

void m0_net_test_stats_ut ( void  )

Definition at line 228 of file stats.c.

Here is the call graph for this function:

◆ m0_net_test_timestamp_ut()

void m0_net_test_timestamp_ut ( void  )

Definition at line 277 of file stats.c.

Here is the call graph for this function:

◆ sample_check()

static void sample_check ( struct m0_net_test_stats stats,
struct stats_expected expected 
)
static

Definition at line 69 of file stats.c.

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

◆ STATS_EXPECTED() [1/5]

STATS_EXPECTED ( one_value  ,
,
,
,
1.  ,
1.  ,
0.   
)

◆ STATS_EXPECTED() [2/5]

STATS_EXPECTED ( five_values  ,
,
,
,
15.  ,
3.  ,
1.  58113883 
)

◆ STATS_EXPECTED() [3/5]

STATS_EXPECTED ( zero_values  ,
,
,
,
0.  ,
0.  ,
0.   
)

◆ STATS_EXPECTED() [4/5]

STATS_EXPECTED ( million_values  ,
STATS_ONE_MILLION  ,
ULONG_MAX  ,
ULONG_MAX  ,
1. *ULONG_MAX *  STATS_ONE_MILLION,
ULONG_MAX  ,
0.   
)

◆ STATS_EXPECTED() [5/5]

STATS_EXPECTED ( one_plus_five_values  ,
,
,
,
16.  ,
16./  6,
1.  632993161 
)

◆ STATS_SAMPLE() [1/2]

STATS_SAMPLE ( one_value  )

◆ STATS_SAMPLE() [2/2]

STATS_SAMPLE ( five_values  )

◆ stats_serialize_ut()

static void stats_serialize_ut ( struct m0_net_test_stats stats)
static

Definition at line 100 of file stats.c.

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

◆ stats_time_ut()

static void stats_time_ut ( void  )
static

Definition at line 195 of file stats.c.

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