3 * Copyright 2015 gRPC authors.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #ifndef GRPC_SUPPORT_HISTOGRAM_H
20 #define GRPC_SUPPORT_HISTOGRAM_H
22 #include <grpc/support/port_platform.h>
30 typedef struct grpc_histogram grpc_histogram;
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);
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
40 int grpc_histogram_merge(grpc_histogram* dst, const grpc_histogram* src);
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);
52 const uint32_t* grpc_histogram_get_contents(grpc_histogram* histogram,
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);
63 #endif /* GRPC_SUPPORT_HISTOGRAM_H */