histogram.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. *
  3. * Copyright 2015 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. #ifndef GRPC_SUPPORT_HISTOGRAM_H
  19. #define GRPC_SUPPORT_HISTOGRAM_H
  20. #include <grpc/support/port_platform.h>
  21. #include <stddef.h>
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. typedef struct grpc_histogram grpc_histogram;
  26. grpc_histogram* grpc_histogram_create(double resolution,
  27. double max_bucket_start);
  28. void grpc_histogram_destroy(grpc_histogram* h);
  29. void grpc_histogram_add(grpc_histogram* h, double x);
  30. /** The following merges the second histogram into the first. It only works
  31. if they have the same buckets and resolution. Returns 0 on failure, 1
  32. on success */
  33. int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src);
  34. double grpc_histogram_percentile(grpc_histogram* histogram, double percentile);
  35. double grpc_histogram_mean(grpc_histogram* histogram);
  36. double grpc_histogram_stddev(grpc_histogram* histogram);
  37. double grpc_histogram_variance(grpc_histogram* histogram);
  38. double grpc_histogram_maximum(grpc_histogram* histogram);
  39. double grpc_histogram_minimum(grpc_histogram* histogram);
  40. double grpc_histogram_count(grpc_histogram* histogram);
  41. double grpc_histogram_sum(grpc_histogram* histogram);
  42. double grpc_histogram_sum_of_squares(grpc_histogram* histogram);
  43. const uint32_t* grpc_histogram_get_contents(grpc_histogram* histogram,
  44. size_t* count);
  45. void grpc_histogram_merge_contents(grpc_histogram* histogram,
  46. const uint32_t* data, size_t data_count,
  47. double min_seen, double max_seen, double sum,
  48. double sum_of_squares, double count);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* GRPC_SUPPORT_HISTOGRAM_H */