Commit f5b01987 authored by wangyao02's avatar wangyao02

- hide cdf and percentiles in LatencyRecorder::hide

- fix divide by zero error caused by output struct Stat while changing by sampling thread
parent ca7a3705
......@@ -265,6 +265,8 @@ void LatencyRecorder::hide() {
_latency_p3.hide();
_latency_999.hide();
_latency_9999.hide();
_latency_cdf.hide();
_latency_percentiles.hide();
}
LatencyRecorder& LatencyRecorder::operator<<(int64_t latency) {
......
......@@ -35,16 +35,19 @@ struct Stat {
int64_t num;
int64_t get_average_int() const {
if (num == 0) {
//num can be changed by sampling thread, use tmp_num
int64_t tmp_num = num;
if (tmp_num == 0) {
return 0;
}
return sum / (int64_t)num;
return sum / (int64_t)tmp_num;
}
double get_average_double() const {
if (num == 0) {
int64_t tmp_num = num;
if (tmp_num == 0) {
return 0.0;
}
return (double)sum / (double)num;
return (double)sum / (double)tmp_num;
}
Stat operator-(const Stat& rhs) const {
return Stat(sum - rhs.sum, num - rhs.num);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment