[PATCH 3/3] stats: simplification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 server/display-channel.c | 80 +++++++++++++++---------------------------------
 1 file changed, 25 insertions(+), 55 deletions(-)

diff --git a/server/display-channel.c b/server/display-channel.c
index 4e5e8bb..f3ceb28 100644
--- a/server/display-channel.c
+++ b/server/display-channel.c
@@ -53,6 +53,16 @@ void display_channel_compress_stats_print(const DisplayChannel *display_channel)
     spice_return_if_fail(display_channel);
 
 #ifdef COMPRESS_STAT
+#define STAT_PRINT(name, count, orig_size, comp_size, total) \
+    spice_info(name STAT_FMT, count, stat_byte_to_mega(orig_size), \
+               stat_byte_to_mega(comp_size), stat_cpu_time_to_sec(total))
+#define STAT_PRINT_ONE(name, field) \
+    STAT_PRINT(name, \
+               display_channel->field.count, \
+               display_channel->field.orig_size, \
+               display_channel->field.comp_size, \
+               display_channel->field.total)
+
     uint64_t glz_enc_size;
 
     glz_enc_size = display_channel->enable_zlib_glz_wrap ?
@@ -61,84 +71,44 @@ 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     " 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     " 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      " 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 " 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       " 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     " 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" 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      " 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)
-               );
+    STAT_PRINT_ONE("OFF      ", off_stat);
+    STAT_PRINT_ONE("QUIC     ", quic_stat);
+    STAT_PRINT_ONE("GLZ      ", glz_stat);
+    STAT_PRINT_ONE("ZLIB GLZ ", zlib_glz_stat);
+    STAT_PRINT_ONE("LZ       ", lz_stat);
+    STAT_PRINT_ONE("JPEG     ", jpeg_stat);
+    STAT_PRINT_ONE("JPEG-RGBA", jpeg_alpha_stat);
+    STAT_PRINT_ONE("LZ4      ", lz4_stat);
     spice_info("-------------------------------------------------------------------");
-    spice_info("Total    " STAT_FMT,
+    STAT_PRINT    ("Total    ",
                display_channel->lz_stat.count + display_channel->glz_stat.count +
                                                 display_channel->off_stat.count +
                                                 display_channel->quic_stat.count +
                                                 display_channel->jpeg_stat.count +
                                                 display_channel->lz4_stat.count +
                                                 display_channel->jpeg_alpha_stat.count,
-               stat_byte_to_mega(display_channel->lz_stat.orig_size +
+               display_channel->lz_stat.orig_size +
                                  display_channel->glz_stat.orig_size +
                                  display_channel->off_stat.orig_size +
                                  display_channel->quic_stat.orig_size +
                                  display_channel->jpeg_stat.orig_size +
                                  display_channel->lz4_stat.orig_size +
-                                 display_channel->jpeg_alpha_stat.orig_size),
-               stat_byte_to_mega(display_channel->lz_stat.comp_size +
+                                 display_channel->jpeg_alpha_stat.orig_size,
+               display_channel->lz_stat.comp_size +
                                  glz_enc_size +
                                  display_channel->off_stat.comp_size +
                                  display_channel->quic_stat.comp_size +
                                  display_channel->jpeg_stat.comp_size +
                                  display_channel->lz4_stat.comp_size +
-                                 display_channel->jpeg_alpha_stat.comp_size),
-               stat_cpu_time_to_sec(display_channel->lz_stat.total +
+                                 display_channel->jpeg_alpha_stat.comp_size,
+               display_channel->lz_stat.total +
                                     display_channel->glz_stat.total +
                                     display_channel->zlib_glz_stat.total +
                                     display_channel->off_stat.total +
                                     display_channel->quic_stat.total +
                                     display_channel->jpeg_stat.total +
                                     display_channel->lz4_stat.total +
-                                    display_channel->jpeg_alpha_stat.total)
+                                    display_channel->jpeg_alpha_stat.total
                );
 #endif
 }
-- 
2.7.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]