hw/arm/allwinner-h3: add EMAC ethernet device
[qemu/ar7.git] / include / qemu / qdist.h
blobbfb3211537316288239f6021585d35f0eff44004
1 /*
2 * Copyright (C) 2016, Emilio G. Cota <cota@braap.org>
4 * License: GNU GPL, version 2 or later.
5 * See the COPYING file in the top-level directory.
6 */
7 #ifndef QEMU_QDIST_H
8 #define QEMU_QDIST_H
10 #include "qemu/bitops.h"
13 * Samples with the same 'x value' end up in the same qdist_entry,
14 * e.g. inc(0.1) and inc(0.1) end up as {x=0.1, count=2}.
16 * Binning happens only at print time, so that we retain the flexibility to
17 * choose the binning. This might not be ideal for workloads that do not care
18 * much about precision and insert many samples all with different x values;
19 * in that case, pre-binning (e.g. entering both 0.115 and 0.097 as 0.1)
20 * should be considered.
22 struct qdist_entry {
23 double x;
24 unsigned long count;
27 struct qdist {
28 struct qdist_entry *entries;
29 size_t n;
30 size_t size;
33 #define QDIST_PR_BORDER BIT(0)
34 #define QDIST_PR_LABELS BIT(1)
35 /* the remaining options only work if PR_LABELS is set */
36 #define QDIST_PR_NODECIMAL BIT(2)
37 #define QDIST_PR_PERCENT BIT(3)
38 #define QDIST_PR_100X BIT(4)
39 #define QDIST_PR_NOBINRANGE BIT(5)
41 void qdist_init(struct qdist *dist);
42 void qdist_destroy(struct qdist *dist);
44 void qdist_add(struct qdist *dist, double x, long count);
45 void qdist_inc(struct qdist *dist, double x);
46 double qdist_xmin(const struct qdist *dist);
47 double qdist_xmax(const struct qdist *dist);
48 double qdist_avg(const struct qdist *dist);
49 unsigned long qdist_sample_count(const struct qdist *dist);
50 size_t qdist_unique_entries(const struct qdist *dist);
52 /* callers must free the returned string with g_free() */
53 char *qdist_pr_plain(const struct qdist *dist, size_t n_groups);
55 /* callers must free the returned string with g_free() */
56 char *qdist_pr(const struct qdist *dist, size_t n_groups, uint32_t opt);
58 /* Only qdist code and test code should ever call this function */
59 void qdist_bin__internal(struct qdist *to, const struct qdist *from, size_t n);
61 #endif /* QEMU_QDIST_H */