File: histogram.h

package info (click to toggle)
xfsprogs 6.17.0-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 11,324 kB
  • sloc: ansic: 167,334; sh: 4,604; makefile: 1,336; python: 835; cpp: 5
file content (77 lines) | stat: -rw-r--r-- 1,963 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
 * Copyright (c) 2012 Red Hat, Inc.
 * Copyright (c) 2017-2024 Oracle.
 * All Rights Reserved.
 */
#ifndef __LIBFROG_HISTOGRAM_H__
#define __LIBFROG_HISTOGRAM_H__

struct histbucket {
	/* Low and high size of this bucket */
	long long		low;
	long long		high;

	/* Count of observations recorded */
	long long		nr_obs;

	/* Sum of values recorded */
	long long		sum;
};

struct histogram {
	/* Sum of all values recorded */
	long long		tot_sum;

	/* Count of all observations recorded */
	long long		tot_obs;

	struct histbucket	*buckets;

	/* Number of buckets */
	unsigned int		nr_buckets;
};

struct histogram_cdf {
	/* histogram from which this cdf was computed */
	const struct histogram	*histogram;

	/* distribution information */
	struct histbucket	*buckets;
};

int hist_add_bucket(struct histogram *hs, long long bucket_low);
void hist_add(struct histogram *hs, long long value);
void hist_init(struct histogram *hs);
void hist_prepare(struct histogram *hs, long long maxvalue);
void hist_free(struct histogram *hs);

struct histogram_strings {
	/* What does each sum represent? ("free blocks") */
	const char		*sum;

	/* What does each observation represent? ("free extents") */
	const char		*observations;

	/* What does sum / observation represent? ("average extent length") */
	const char		*averages;
};

void hist_print(const struct histogram *hs,
		const struct histogram_strings *hstr);
void hist_summarize(const struct histogram *hs,
		const struct histogram_strings *hstr);

static inline unsigned int hist_buckets(const struct histogram *hs)
{
	return hs->nr_buckets;
}

struct histogram_cdf *hist_cdf(const struct histogram *hs);
void histcdf_free(struct histogram_cdf *cdf);

void hist_import(struct histogram *dest, const struct histogram *src);
void hist_move(struct histogram *dest, struct histogram *src);

#endif /* __LIBFROG_HISTOGRAM_H__ */