QuantileEstimator.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright 2018-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <folly/stats/QuantileEstimator-defs.h>
  17. namespace folly {
  18. namespace detail {
  19. QuantileEstimates estimatesFromDigest(
  20. const TDigest& digest,
  21. Range<const double*> quantiles) {
  22. QuantileEstimates result;
  23. result.quantiles.reserve(quantiles.size());
  24. result.sum = digest.sum();
  25. result.count = digest.count();
  26. for (auto it = quantiles.begin(); it != quantiles.end(); ++it) {
  27. result.quantiles.push_back(
  28. std::make_pair(*it, digest.estimateQuantile(*it)));
  29. }
  30. return result;
  31. }
  32. } // namespace detail
  33. template class SimpleQuantileEstimator<std::chrono::steady_clock>;
  34. template class SlidingWindowQuantileEstimator<std::chrono::steady_clock>;
  35. } // namespace folly