Debian Codegraph @

src/include/histogram.h

raw symbols SCIP
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 #include <stdint.h>
3 #include <stdio.h>
4
5 struct histogram {
6 unsigned long *buckets;
7 unsigned long width; // interval covered by one bucket
8 unsigned long num; // number of buckets
9 unsigned long events; // number of events logged
10
11 unsigned long *oflows; // events when overflow happened
12 unsigned long oflow_bufsize; // number of overflows that can be logged
13 unsigned long oflow_count; // number of events that overflowed
14 uint64_t oflow_magnitude; // sum of how many buckets overflowed by
15 };
16
17 struct histoset {
18 struct histogram *histos; // Group of related histograms (e.g. per cpu)
19 struct histogram *sum; // Accumulates events from all histos
20 unsigned long num_histos; // Not including sum
21 unsigned long num_buckets;
22 };
23
24 #define HIST_OVERFLOW 1
25 #define HIST_OVERFLOW_MAG 2
26 #define HIST_OVERFLOW_LOG 4
27
28 int hist_init(struct histogram *h, unsigned long width, unsigned long num);
29 int hist_init_oflow(struct histogram *h, unsigned long num);
30 void hist_destroy(struct histogram *h);
31 int hist_sample(struct histogram *h, uint64_t sample);
32
33 #define HSET_PRINT_SUM 1
34 #define HSET_PRINT_JSON 2
35
36 int hset_init(struct histoset *hs, unsigned long histos, unsigned long bucket_width,
37 unsigned long num_buckets, unsigned long overflow);
38 void hset_destroy(struct histoset *hs);
39 void hset_print_bucket(struct histoset *hs, FILE *f, const char *pre,
40 unsigned long bucket, unsigned long flags);
41 void hist_print_json(struct histogram *h, FILE *f);
42 void hist_print_oflows(struct histogram *h, FILE *f);