Tor 0.4.9.0-alpha-dev
Macros | Functions
stats.h File Reference

Header for stats.c. More...

Go to the source code of this file.

Macros

#define DEFAULT_STATS_N_EWMA_COUNT   100
 
#define stats_update_running_avg(avg, value)    n_count_ewma_double(avg, value, DEFAULT_STATS_N_EWMA_COUNT)
 

Functions

static double n_count_ewma_double (double avg, double value, uint64_t N)
 

Detailed Description

Header for stats.c.

Definition in file stats.h.

Macro Definition Documentation

◆ DEFAULT_STATS_N_EWMA_COUNT

#define DEFAULT_STATS_N_EWMA_COUNT   100

Definition at line 38 of file stats.h.

◆ stats_update_running_avg

#define stats_update_running_avg (   avg,
  value 
)     n_count_ewma_double(avg, value, DEFAULT_STATS_N_EWMA_COUNT)

Definition at line 39 of file stats.h.

Function Documentation

◆ n_count_ewma_double()

static double n_count_ewma_double ( double  avg,
double  value,
uint64_t  N 
)
inlinestatic

Compute an N-count EWMA, aka N-EWMA. N-EWMA is defined as: EWMA = alpha*value + (1-alpha)*EWMA_prev with alpha = 2/(N+1).

This works out to: EWMA = value*2/(N+1) + EMA_prev*(N-1)/(N+1) = (value*2 + EWMA_prev*(N-1))/(N+1)

Definition at line 23 of file stats.h.