pair<uint64_t, T> last;
pair<uint64_t, T> cur;
avg_tracker() : last(0, 0), cur(0, 0) {}
- T avg() const {
+ T current_avg() const {
if (cur.first == last.first)
- return cur.first ?
- cur.second / cur.first :
- 0; // no change, report avg over all time
+ return 0;
return (cur.second - last.second) / (cur.first - last.first);
}
void consume_next(const pair<uint64_t, T> &next) {
objectstore_perf_stat_t get_cur_stats() const {
objectstore_perf_stat_t ret;
- ret.os_commit_latency = os_commit_latency.avg();
- ret.os_apply_latency = os_apply_latency.avg();
+ ret.os_commit_latency = os_commit_latency.current_avg();
+ ret.os_apply_latency = os_apply_latency.current_avg();
return ret;
}
objectstore_perf_stat_t get_cur_stats() const {
objectstore_perf_stat_t ret;
- ret.os_commit_latency = os_commit_latency.avg();
- ret.os_apply_latency = os_apply_latency.avg();
+ ret.os_commit_latency = os_commit_latency.current_avg();
+ ret.os_apply_latency = os_apply_latency.current_avg();
return ret;
}