* averaging and reporting unused and low-use circuits here */
if (circ->ccontrol->max_rtt_usec != circ->ccontrol->min_rtt_usec) {
stats_circ_close_ss_cwnd_ma_count++;
- STATS_UPDATE_AVG(cc_stats_circ_close_ss_cwnd_ma,
- circ->ccontrol->cwnd, stats_circ_close_ss_cwnd_ma_count);
+ cc_stats_circ_close_ss_cwnd_ma =
+ stats_update_running_avg(cc_stats_circ_close_ss_cwnd_ma,
+ circ->ccontrol->cwnd,
+ stats_circ_close_ss_cwnd_ma_count);
}
} else {
stats_circ_close_cwnd_ma_count++;
- STATS_UPDATE_AVG(cc_stats_circ_close_cwnd_ma,
- circ->ccontrol->cwnd, stats_circ_close_cwnd_ma_count);
+ cc_stats_circ_close_cwnd_ma =
+ stats_update_running_avg(cc_stats_circ_close_cwnd_ma,
+ circ->ccontrol->cwnd,
+ stats_circ_close_cwnd_ma_count);
}
}
tor_trace(TR_SUBSYS(cc), TR_EV(flow_decide_xoff_sending), stream);
cc_stats_flow_xoff_outbuf_ma_count++;
- STATS_UPDATE_AVG(cc_stats_flow_xoff_outbuf_ma,
- total_buffered, cc_stats_flow_xoff_outbuf_ma_count);
+ cc_stats_flow_xoff_outbuf_ma =
+ stats_update_running_avg(cc_stats_flow_xoff_outbuf_ma,
+ total_buffered,
+ cc_stats_flow_xoff_outbuf_ma_count);
circuit_send_stream_xoff(stream);
tor_trace(TR_SUBSYS(cc), TR_EV(flow_decide_xon_rate_change), stream);
cc_stats_flow_xon_outbuf_ma_count++;
- STATS_UPDATE_AVG(cc_stats_flow_xon_outbuf_ma,
- total_buffered, cc_stats_flow_xon_outbuf_ma_count);
+ cc_stats_flow_xon_outbuf_ma =
+ stats_update_running_avg(cc_stats_flow_xon_outbuf_ma,
+ total_buffered,
+ cc_stats_flow_xon_outbuf_ma_count);
circuit_send_stream_xon(stream);
}
/* Update running cc->cwnd average for metrics. */
stats_cwnd_exit_ss_ma_count++;
- STATS_UPDATE_AVG(cc_stats_vegas_exit_ss_cwnd_ma,
- cc->cwnd, stats_cwnd_exit_ss_ma_count);
+ cc_stats_vegas_exit_ss_cwnd_ma =
+ stats_update_running_avg(cc_stats_vegas_exit_ss_cwnd_ma,
+ cc->cwnd, stats_cwnd_exit_ss_ma_count);
/* We need to report that slow start has exited ASAP,
* for sbws bandwidth measurement. */
/** 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)
+static inline double
+stats_update_running_avg(double avg, double value, double n)
+{
+ return ((avg * (n - 1)) + value) / n;
+}
#endif /* !defined(TOR_STATS_H) */