C# 中内存占用最低的最快串行器和解串器?

发布于 2024-07-15 04:41:31 字数 281 浏览 4 评论 0原文

我目前正在使用二进制格式化程序(Remoting)来序列化和反序列化对象,以便在我的 LAN 中发送。

我最近从 2.0 升级到 .NET 3.5。 3.5 是否引入了任何新类型来提高序列化性能?

我查看了 DataContractSerializer,但这会将任何内容序列化为底层 XML 权利……这必然会增加内存占用。

通过 LAN 发送对象最快的序列化程序是什么? 我不关心互操作或版本控制...... 我需要速度!

我对第三方开源替代品持开放态度。

I am currently using the binary formatter (Remoting) to serialize and deserialize objects for sending around my LAN.

I have recently upgraded from 2.0 to .NET 3.5. Has 3.5 introduced any new types to improve serialization performance?

I’ve looked at the DataContractSerializer, but this serializes anything to underlying XML right … which must increase the memory footprint.

What’s the fastest serializer for sending objects across my LAN? I don’t care a about interop or versioning …. I need speed!

I am open to third-party open source alternatives.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

静若繁花 2024-07-22 04:41:32

在 @Luke 链接的性能比较中,请注意 与其他 MS 序列化程序相比,DataContractJsonSerializer 的性能非常好。

鉴于 JSON 的普遍存在,以及使用 DataContractJsonSerializer 的便利性,我认为没有太多理由使用“协议缓冲区”。 当在语言和平台之间跳转时,JSON 会更容易调试,并且它会进行精美的压缩。

(我喜欢 Google 如何采用 CS 101 概念并因实现它们而闻名。在 C 语言中,我们将“协议缓冲区”称为“结构”。它们工作得很好。)

In the performance comparison linked by @Luke, notice that DataContractJsonSerializer performs very well compared to the other MS serializers.

Given the ubiquity of JSON, and the ease of which you can use DataContractJsonSerializer, I don't see much reason to use "protocol buffers". JSON will be easier to debug when bouncing between languages and platforms, and it will compress beautifully.

(I love how Google takes CS 101 concepts and becomes famous for implementing them. In C, we call "protocol buffer" "struct"s. They work great.)

红衣飘飘貌似仙 2024-07-22 04:41:32

正如我在这个答案中演示的,生成的代码可能是最快的序列化器。 然而它还处于早期阶段,仍然缺乏其他序列化器提供的一些功能。

As I demonstrated in this answer the generated code might be the fastest serializer. However it is in an early stage and still lacks a couple of features that other serializers offer.

与他有关 2024-07-22 04:41:31

听起来协议缓冲区可能就是您正在寻找的东西。

我知道三种 .NET 实现:protobuf-net、< a href="http://code.google.com/p/protobuf-csharp-port/" rel="noreferrer">protobuf-csharp-port 和 原型#

性能比较表明,Protocol Buffer 的性能优于内置序列化器大小和序列化/反序列化速度。

It sounds like Protocol Buffers might be what you're looking for.

There are three .NET implementations that I'm aware of: protobuf-net, protobuf-csharp-port and Proto#.

The performance comparisons show that Protocol Buffers outperform the built-in serializers in terms of both size and serialization/deserialization speed.

奢华的一滴泪 2024-07-22 04:41:31

我有一些领先的.NET序列化器的基准 基于 Northwind 数据集可用。

@marcgravell 二进制 protobuf-net 是基准测试中最快的实现,比 BCL 中可用的 Microsoft 最快序列化器(XML DataContractSerializer)快大约 7 倍

Microsoft 的 JsonDataContractSerializer 相当慢 - 比 protobuf-net 慢 9 倍 以上,比我自己的 JsonSerializer

I have some benchmarks for the leading .NET serializers available based on the Northwind dataset.

@marcgravell binary protobuf-net is the fastest implementations benchmarked that is about 7x faster than Microsoft fastest serializer available (the XML DataContractSerializer) in the BCL.

Microsoft's JsonDataContractSerializer is pretty slow - over 9x slower that protobuf-net and over 3.6x slower than my own JsonSerializer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文