[Kamailio-Devel] calculating average statistics
Henning Westerholt
henning.westerholt at 1und1.de
Tue Aug 26 12:28:45 CEST 2008
On Monday 25 August 2008, Juha Heinanen wrote:
> i'm not sure if current statistics.h interface allows keeping track of
> average of something. if i use get_stat to get the current average and
> current count value, do my calculation of new average and then update
> average and count values, some other process may have in the meanwhile
> done its update and thus messed up my calculation.
>
> in order to solve this, should there be a new update_average_stat macro
> that does the above under a lock?
Hi Juha,
at the moment there are two ways of updating statistic values atomically. If
NO_ATOMIC_OPS is defined, then one big lock is used. In this way i think it
should not that difficult to implement a function like you described. But
from a performance POV its better to use the atomic functions defined in
atomic.h, which are the default i think. This functions are defined as some
assembler instructions, and its probably a little harder to define here
something like this.
But i think it would be a good to have such a function.
Cheers,
Henning
More information about the Devel
mailing list