proxygen
folly::Histogram< T >::AvgFromBucket Struct Reference

#include <Histogram.h>

Public Member Functions

ValueType operator() (const Bucket &bucket) const
 

Detailed Description

template<typename T>
struct folly::Histogram< T >::AvgFromBucket

Definition at line 456 of file Histogram.h.

Member Function Documentation

template<typename T>
ValueType folly::Histogram< T >::AvgFromBucket::operator() ( const Bucket bucket) const
inline

Definition at line 457 of file Histogram.h.

References folly::detail::Bucket< T >::count, int64_t, and folly::detail::Bucket< T >::sum.

457  {
458  if (bucket.count == 0) {
459  return ValueType(0);
460  }
461  // Cast bucket.count to a signed integer type. This ensures that we
462  // perform division properly here: If bucket.sum is a signed integer
463  // type but we divide by an unsigned number, unsigned division will be
464  // performed and bucket.sum will be converted to unsigned first.
465  // If bucket.sum is unsigned, the code will still do unsigned division
466  // correctly.
467  //
468  // The only downside is if bucket.count is large enough to be negative
469  // when treated as signed. That should be extremely unlikely, though.
470  return bucket.sum / static_cast<int64_t>(bucket.count);
471  }

The documentation for this struct was generated from the following file: