return cd->mean;
}
-double
+float
rspamd_set_counter_ema (struct rspamd_counter_data *cd,
- gdouble value,
- gdouble alpha)
+ float value,
+ float alpha)
{
- gdouble diff, incr;
+ float diff, incr;
/* Cumulative moving average using per-process counter data */
if (cd->number == 0) {
diff = value - cd->mean;
incr = diff * alpha;
cd->mean += incr;
- cd->stddev = (1 - alpha) * (cd->stddev + diff * incr);
+ cd->stddev = (1.0f - alpha) * (cd->stddev + diff * incr);
cd->number ++;
return cd->mean;
GError **err);
struct rspamd_counter_data {
- gdouble mean;
- gdouble stddev;
+ float mean;
+ float stddev;
guint64 number;
};
* @param alpha decay coefficient (0..1)
* @return new counter value
*/
-double rspamd_set_counter_ema (struct rspamd_counter_data *cd,
- gdouble value,
- gdouble alpha);
+float rspamd_set_counter_ema (struct rspamd_counter_data *cd,
+ float value,
+ float alpha);
/**
* Sets counter's data using flat moving average