[Spice-devel] [PATCH 3/3] stats: simplification

Christophe Fergeau cfergeau at redhat.com
Fri May 13 15:03:38 UTC 2016


Why not merge this with patch 1, and have a helper taking a stat_info_t
rather than having these macros?

Christophe

On Fri, May 13, 2016 at 02:55:58PM +0100, Frediano Ziglio wrote:
> ---
>  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 at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160513/cb8e7714/attachment-0001.sig>


More information about the Spice-devel mailing list