压缩XML度量。 [英] Compression XML metrics .

查看:125
本文介绍了压缩XML度量。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户端服务器应用程序,通过TCP / IP从客户端向服务器发送XML,然后广播到其他客户端。我如何知道XML的最小尺寸是什么,通过压缩XML而不是通过常规流发送来保证性能提高。



有什么好的指标在这个或者例子上?

解决方案

Xml通常压缩得很好,因为它往往有很多重复。

另一种选择是交换为二进制格式; BinaryFormatter或NetDataContractSerializer是很简单的选项,但是与xml相比,它们都是非常不兼容的(例如使用java)。



另一种选择是可移植的二进制格式,例如google的缓冲器。我维护了一个名为 protobuf-net 的.NET / C#版本。这是为了与常规.NET方法(例如XmlSerializer / DataContractSerializer)并行兼容,但是比xml小得多,并且对于序列化和反序列化需要少得多的处理(CPU等)。



此网页显示一些数字为XmlSerializer,DataContractSerializer和protobuf-net;我认为包括有/没有压缩的统计,但它们似乎已经消失...



[update]是QuickStart项目中的TCP / IP示例。


I have a client server application that sends XML over TCP/IP from client to server and then broadcast out to other clients. How do i know at what the minimun size of the XML that would warrant a performance improvement by compression the XML rather than sending over the regular stream.

Are there any good metrics on this or examples?

解决方案

Xml usually compresses very well, as it tends to have a lot of repetition.

Another option would be to swap to a binary format; BinaryFormatter or NetDataContractSerializer are simple options, but both are notoriously incompatible (for example with java) compared with xml.

Another option would be a portable binary format such as google's "protocol buffers". I maintain a .NET/C# version of this called protobuf-net. This is designed to be side-by-side compatible with regular .NET approaches (such as XmlSerializer / DataContractSerializer), but is much smaller than xml, and requires significantly less processing (CPU etc) for both serialization and deserialization.

This page shows some numbers for XmlSerializer, DataContractSerializer and protobuf-net; I thought it included stats with/without compression, but they seem to have vanished...

[update] I should have said - there is a TCP/IP example in the QuickStart project.

这篇关于压缩XML度量。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆