[Kamailio-Devel] calculating average statistics
Juha Heinanen
jh at tutpro.com
Tue Aug 26 19:24:45 CEST 2008
Henning Westerholt writes:
> at the moment there are two ways of updating statistic values
> atomically. If NO_ATOMIC_OPS is defined, then one big lock is used.
> 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.
henning,
i looked at atomic.h and it seems that NO_ATOMIC_OPS is only defined if
CPU is NOT i386 or CPU_x86_64. in i386 and x86_64 case, atomic.h
provides assembly code for functions atomic_set, atomic_add, atomic_sub,
atomic_inc, and atomic_dec. they are not enough for average
calculation. so average calculation has to be done within
lock_get/lock_release.
i could try to add to statistics.h macros
reset_ave(_ave_var, _count_var)
update_ave(_ave_var, _count_var, _new_val)
get_ave(_ave_var)
or does someone have better ideas?
-- juha
More information about the Devel
mailing list