cctools
histogram.h
Go to the documentation of this file.
1/*
2Copyright (C) 2022 The University of Notre Dame
3This software is distributed under the GNU General Public License.
4See the file COPYING for details.
5*/
6
7#ifndef HISTOGRAM_H
8#define HISTOGRAM_H
9
10#include "int_sizes.h"
11
65struct histogram *histogram_create(double bucket_size);
66
71void histogram_clear(struct histogram *h);
72
77void histogram_delete(struct histogram *h);
78
84int histogram_size(struct histogram *h);
85
87double *histogram_buckets(struct histogram *h);
88
90double histogram_bucket_size(struct histogram *h);
91
98int histogram_insert(struct histogram *h, double value);
99
106int histogram_count(struct histogram *h, double value);
107
114void histogram_set_bucket(struct histogram *h, double value, int count);
115
122void histogram_attach_data(struct histogram *h, double value, void *data);
123
130void *histogram_get_data(struct histogram *h, double value);
131
137int histogram_total_count(struct histogram *h);
138
144double histogram_max_value(struct histogram *h);
145
151double histogram_min_value(struct histogram *h);
152
153
159double histogram_round_up(struct histogram *h, double test_value);
160
161
167double histogram_mode(struct histogram *h);
168
169#endif
void histogram_delete(struct histogram *h)
Delete a histogram.
int histogram_size(struct histogram *h)
Count the number of active buckets.
double histogram_max_value(struct histogram *h)
Return the maximum value inserted in the histogram.
struct histogram * histogram_create(double bucket_size)
Create a new histogram.
double * histogram_buckets(struct histogram *h)
Returns an ordered array with the start values of the active buckets.
double histogram_min_value(struct histogram *h)
Return the minimum value inserted in the histogram.
void histogram_clear(struct histogram *h)
Remove all entries from a histogram.
int histogram_insert(struct histogram *h, double value)
Add value to histogram.
int histogram_count(struct histogram *h, double value)
Look up the count for the bucket of the given value.
int histogram_total_count(struct histogram *h)
Return the total number of samples in the histogram.
void histogram_set_bucket(struct histogram *h, double value, int count)
Manually set the count for a bucket.
void histogram_attach_data(struct histogram *h, double value, void *data)
Attach custom data to bucket.
double histogram_mode(struct histogram *h)
Return the mode of the histogram.
double histogram_round_up(struct histogram *h, double test_value)
Return the largest value of the bucket that test_value would faill in.
double histogram_bucket_size(struct histogram *h)
Returns the bucket size.
void * histogram_get_data(struct histogram *h, double value)
Retrieved custom data attached to the bucket.