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 19 #ifndef GRPC_TEST_CORE_TEST_UTIL_HISTOGRAM_H 20 #define GRPC_TEST_CORE_TEST_UTIL_HISTOGRAM_H 21 22 #include <grpc/support/port_platform.h> 23 #include <stddef.h> 24 #include <stdint.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 typedef struct grpc_histogram grpc_histogram; 31 32 grpc_histogram* grpc_histogram_create(double resolution, 33 double max_bucket_start); 34 void grpc_histogram_destroy(grpc_histogram* h); 35 void grpc_histogram_add(grpc_histogram* h, double x); 36 37 /// The following merges the second histogram into the first. It only works 38 /// if they have the same buckets and resolution. Returns 0 on failure, 1 39 /// on success 40 int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src); 41 42 double grpc_histogram_percentile(grpc_histogram* histogram, double percentile); 43 double grpc_histogram_mean(grpc_histogram* histogram); 44 double grpc_histogram_stddev(grpc_histogram* histogram); 45 double grpc_histogram_variance(grpc_histogram* histogram); 46 double grpc_histogram_maximum(grpc_histogram* histogram); 47 double grpc_histogram_minimum(grpc_histogram* histogram); 48 double grpc_histogram_count(grpc_histogram* histogram); 49 double grpc_histogram_sum(grpc_histogram* histogram); 50 double grpc_histogram_sum_of_squares(grpc_histogram* histogram); 51 52 const uint32_t* grpc_histogram_get_contents(grpc_histogram* histogram, 53 size_t* count); 54 void grpc_histogram_merge_contents(grpc_histogram* histogram, 55 const uint32_t* data, size_t data_count, 56 double min_seen, double max_seen, double sum, 57 double sum_of_squares, double count); 58 59 #ifdef __cplusplus 60 } 61 #endif 62 63 #endif // GRPC_TEST_CORE_TEST_UTIL_HISTOGRAM_H 64