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