diff mbox

[RFC,v2,3/4] hmp: Add a helper function for printing out a Rolling Statistics set

Message ID 1425464979-20578-4-git-send-email-dgilbert@redhat.com
State New
Headers show

Commit Message

Dr. David Alan Gilbert March 4, 2015, 10:29 a.m. UTC
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 hmp.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox

Patch

diff --git a/hmp.c b/hmp.c
index 735097c..20241d8 100644
--- a/hmp.c
+++ b/hmp.c
@@ -138,6 +138,27 @@  void hmp_info_mice(Monitor *mon, const QDict *qdict)
     qapi_free_MouseInfoList(mice_list);
 }
 
+__attribute__ (( unused )) /* Until later in patch series */
+static void monitor_printf_RollingStats(Monitor *mon, const char *title,
+                                        RollingStats *r)
+{
+    RollingStatsValueList *list_entry = r->values;
+
+    monitor_printf(mon, "%s: Min/Max: %.8g, %.8g Mean: %.8g "
+                        "(Weighted: %.8g) Count: %" PRIu64
+                        " Values: ",
+                   title, r->min, r->max, r->mean, r->weighted_mean, r->count);
+
+    while (list_entry) {
+        monitor_printf(mon, "%.8g@%" PRIu64 "%s",
+                       list_entry->value->value,
+                       list_entry->value->tag,
+                       list_entry->next ? ", " : "");
+        list_entry = list_entry->next;
+    }
+    monitor_printf(mon, "\n");
+}
+
 void hmp_info_migrate(Monitor *mon, const QDict *qdict)
 {
     MigrationInfo *info;