diff options
author | David Goulet <dgoulet@torproject.org> | 2022-11-03 10:43:37 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2022-11-07 09:55:06 -0500 |
commit | c565ef9c58546a815431d575c9ad16fb0bf2dc22 (patch) | |
tree | aef852436c5910f30f6a72774c67609fc91bbb44 /src/lib/math | |
parent | 87e820a0c54e57fc282bb5d2472ef775504be8e0 (diff) | |
download | tor-c565ef9c58546a815431d575c9ad16fb0bf2dc22.tar.gz tor-c565ef9c58546a815431d575c9ad16fb0bf2dc22.zip |
metrics: Add running average of CC cwnd when exiting slow start
Part of #40708
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/lib/math')
-rw-r--r-- | src/lib/math/include.am | 3 | ||||
-rw-r--r-- | src/lib/math/stats.h | 19 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/lib/math/include.am b/src/lib/math/include.am index b2ca280f47..f68b265da7 100644 --- a/src/lib/math/include.am +++ b/src/lib/math/include.am @@ -20,4 +20,5 @@ src_lib_libtor_math_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) noinst_HEADERS += \ src/lib/math/fp.h \ src/lib/math/laplace.h \ - src/lib/math/prob_distr.h + src/lib/math/prob_distr.h \ + src/lib/math/stats.h diff --git a/src/lib/math/stats.h b/src/lib/math/stats.h new file mode 100644 index 0000000000..fae93c6213 --- /dev/null +++ b/src/lib/math/stats.h @@ -0,0 +1,19 @@ +/* Copyright (c) 2022, The Tor Project, Inc. */ +/* See LICENSE for licensing information */ + +/** + * \file stats.h + * + * \brief Header for stats.c + **/ + +#ifndef TOR_STATS_H +#define TOR_STATS_H + +/** Update an average making it a "running average". The "avg" is the current + * value that will be updated to the new one. The "value" is the new value to + * add to the average and "n" is the new count as in including the "value". */ +#define STATS_UPDATE_AVG(avg, value, n) \ + avg = ((avg) * ((n) - 1) + (value)) / (n) + +#endif /* !defined(TOR_STATS_H) */ |