nr rlc stats: make avg time to tx optional

Introduce the function nr_rlc_activate_avg_time_to_tx() to
activate/deactivate collection of avg time to tx stats (which
may have an impact on realtime processing, so better not compute
them when not needed).

Fix a little bug in time_average_get_average() for when there is not stat.
This commit is contained in:
Cedric Roux
2022-08-12 12:19:09 +02:00
committed by Chieh-Chun Chen
parent c0394bc09c
commit 1b029be058
9 changed files with 56 additions and 5 deletions
+11
View File
@@ -61,6 +61,14 @@ void time_average_free(time_average_t *t)
free(t);
}
void time_average_reset(time_average_t *t)
{
t->r.head = t->r.maxsize - 1;
t->r.tail = 0;
t->r.size = 0;
t->accumulated_value = 0;
}
static void remove_old(time_average_t *t, uint64_t time)
{
/* remove old events */
@@ -103,6 +111,9 @@ double time_average_get_average(time_average_t *t, uint64_t time)
{
remove_old(t, time);
if (t->r.size == 0)
return 0;
return (double)t->accumulated_value / t->r.size;
}
+1
View File
@@ -46,6 +46,7 @@ typedef struct {
/* 'duration' is in unit microsecond */
time_average_t *time_average_new(int duration, int initial_size);
void time_average_free(time_average_t *t);
void time_average_reset(time_average_t *t);
/* add a value tagged with time 'time' unit microsecond (it also modifies 't',
* removing all data with time < 'time' - t->duration)