| 221 | } |
| 222 | |
| 223 | value_type get_value(time_t window_size) const override { |
| 224 | detail::Sample<value_type> s; |
| 225 | this->get_span(window_size, &s); |
| 226 | // We may test if the multiplication overflows and use integral ops |
| 227 | // if possible. However signed/unsigned 32-bit/64-bit make the solution |
| 228 | // complex. Since this function is not called often, we use floating |
| 229 | // point for simplicity. |
| 230 | if (s.time_us <= 0) { |
| 231 | return static_cast<value_type>(0); |
| 232 | } |
| 233 | if (butil::is_floating_point<value_type>::value) { |
| 234 | return static_cast<value_type>(s.data * 1000000.0 / s.time_us); |
| 235 | } else { |
| 236 | return static_cast<value_type>(round(s.data * 1000000.0 / s.time_us)); |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | value_type get_value() const { return Base::get_value(); } |
| 241 | }; |
no test coverage detected