MCPcopy Create free account
hub / github.com/apache/brpc / get_value

Method get_value

src/bvar/window.h:223–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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};

Callers 3

take_sampleMethod · 0.45
get_spanMethod · 0.45
get_valueMethod · 0.45

Calls 1

get_spanMethod · 0.80

Tested by

no test coverage detected