From: "Dr. David Alan Gilbert" <dgilb...@redhat.com> Hi, This is an attempt at a generic rolling statistics utility to allow data (e.g. bandwidth usage, times etc) to be collected easily. They hold some basic values (min/max/mean/weighted mean) and the last 'n' raw values. I'd like to use this maybe with fault-tolerance code and want to read the means within qemu but also want to provide the values to higher levels of the stack and to watch what is going on.
This version is lightly tested, and I'm still more interested in if it's the right shape/idea rather than a detailed review. I've included an example use in watching the 'expected downtime' in migration; rather than the current single value we get: HMP: expected downtime stats: Min/Max: 222, 1634 Mean: 983.8 (Weighted: 1005.1253) Count: 141 Values: 1248@39356292, 981@39356395, 774@39356497, 876@39356599, 1040@39356702 QMP: "expected-downtime-stats": { "min": 222, "count": 378, "mean": 1100.2, "max": 1942, "weighted-mean": 1115.710848, "values": [ { "tag": 39380740, "value": 1118 }, { "tag": 39380842, "value": 953 }, { "tag": 39380945, "value": 1017 }, { "tag": 39381048, "value": 1336 }, { "tag": 39381150, "value": 1077 } ] } Dave RFC v2 Wired up a qapi type so that the output is done via qapi; it still seems best to have a separate type with the data and the locking etc. Although that has lost my test harness that was built on my manual formatters. Dr. David Alan Gilbert (4): RollingStats qapi type Rolling statistics utilities hmp: Add a helper function for printing out a Rolling Statistics set Example use of rolling statistics in migration hmp.c | 24 +++++ include/migration/migration.h | 1 + include/qemu/rolling-stats.h | 87 ++++++++++++++++ include/qemu/typedefs.h | 1 + migration/migration.c | 15 +++ qapi-schema.json | 36 ++++++- util/Makefile.objs | 1 + util/rolling-stats.c | 236 ++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 400 insertions(+), 1 deletion(-) create mode 100644 include/qemu/rolling-stats.h create mode 100644 util/rolling-stats.c -- 2.1.0