[Spice-devel] [PATCH 1/3] stats: allow easier change of statistic formats

Frediano Ziglio fziglio at redhat.com
Fri May 13 13:55:56 UTC 2016


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/display-channel.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 1f4d66f..40c76b3 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -46,6 +46,8 @@ void display_channel_compress_stats_reset(DisplayChannel *display)
     stat_reset(&display->lz4_stat);
 }
 
+#define STAT_FMT "\t%8d\t%13.2f\t%12.2f\t%12.2f"
+
 void display_channel_compress_stats_print(const DisplayChannel *display_channel)
 {
     spice_return_if_fail(display_channel);
@@ -59,56 +61,56 @@ void display_channel_compress_stats_print(const DisplayChannel *display_channel)
 
     spice_info("==> Compression stats for display %u", display_channel->common.base.id);
     spice_info("Method   \t  count  \torig_size(MB)\tenc_size(MB)\tenc_time(s)");
-    spice_info("OFF     \t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("OFF     " STAT_FMT,
                display_channel->off_stat.count,
                stat_byte_to_mega(display_channel->off_stat.orig_size),
                stat_byte_to_mega(display_channel->off_stat.comp_size),
                stat_cpu_time_to_sec(display_channel->off_stat.total)
                );
-    spice_info("QUIC     \t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("QUIC     " STAT_FMT,
                display_channel->quic_stat.count,
                stat_byte_to_mega(display_channel->quic_stat.orig_size),
                stat_byte_to_mega(display_channel->quic_stat.comp_size),
                stat_cpu_time_to_sec(display_channel->quic_stat.total)
                );
-    spice_info("GLZ      \t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("GLZ      " STAT_FMT,
                display_channel->glz_stat.count,
                stat_byte_to_mega(display_channel->glz_stat.orig_size),
                stat_byte_to_mega(display_channel->glz_stat.comp_size),
                stat_cpu_time_to_sec(display_channel->glz_stat.total)
                );
-    spice_info("ZLIB GLZ \t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("ZLIB GLZ " STAT_FMT,
                display_channel->zlib_glz_stat.count,
                stat_byte_to_mega(display_channel->zlib_glz_stat.orig_size),
                stat_byte_to_mega(display_channel->zlib_glz_stat.comp_size),
                stat_cpu_time_to_sec(display_channel->zlib_glz_stat.total)
                );
-    spice_info("LZ       \t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("LZ       " STAT_FMT,
                display_channel->lz_stat.count,
                stat_byte_to_mega(display_channel->lz_stat.orig_size),
                stat_byte_to_mega(display_channel->lz_stat.comp_size),
                stat_cpu_time_to_sec(display_channel->lz_stat.total)
                );
-    spice_info("JPEG     \t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("JPEG     " STAT_FMT,
                display_channel->jpeg_stat.count,
                stat_byte_to_mega(display_channel->jpeg_stat.orig_size),
                stat_byte_to_mega(display_channel->jpeg_stat.comp_size),
                stat_cpu_time_to_sec(display_channel->jpeg_stat.total)
                );
-    spice_info("JPEG-RGBA\t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("JPEG-RGBA" STAT_FMT,
                display_channel->jpeg_alpha_stat.count,
                stat_byte_to_mega(display_channel->jpeg_alpha_stat.orig_size),
                stat_byte_to_mega(display_channel->jpeg_alpha_stat.comp_size),
                stat_cpu_time_to_sec(display_channel->jpeg_alpha_stat.total)
                );
-    spice_info("LZ4      \t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("LZ4      " STAT_FMT,
                display_channel->lz4_stat.count,
                stat_byte_to_mega(display_channel->lz4_stat.orig_size),
                stat_byte_to_mega(display_channel->lz4_stat.comp_size),
                stat_cpu_time_to_sec(display_channel->lz4_stat.total)
                );
     spice_info("-------------------------------------------------------------------");
-    spice_info("Total    \t%8d\t%13.2f\t%12.2f\t%12.2f",
+    spice_info("Total    " STAT_FMT,
                display_channel->lz_stat.count + display_channel->glz_stat.count +
                                                 display_channel->off_stat.count +
                                                 display_channel->quic_stat.count +
-- 
2.7.4



More information about the Spice-devel mailing list