问题描述
我正在构建一个分布式 C++ 应用程序,它需要对在不同进程和计算机之间传递的简单数据结构进行大量序列化和反序列化.
I'm building a distributed C++ application that needs to do lots of serialization and deserialization of simple data structures that's being passed between different processes and computers.
我对序列化复杂的类层次结构不感兴趣,但更多的是发送具有一些简单成员(如数字、字符串和数据向量)的结构.数据向量通常可以有好几兆字节大.我担心基于 text/xml 的方法太慢了,我真的不想自己写这个,因为字符串编码和数字字节序等问题可能会使它比表面看起来更复杂.
I'm not interested in serializing complex class hierarchies, but more of sending structures with a few simple members such as number, strings and data vectors. The data vectors can often be many megabytes large. I'm worried that text/xml-based ways of doing it is too slow and I really don't want to write this myself since problems like string encoding and number endianess can make it way more complicated than it looks on the surface.
我一直在研究协议缓冲区和 boost.serialize.根据文档协议缓冲区似乎非常关心性能.Boost 似乎更轻量级,因为您没有用于指定数据格式的外部语言,我觉得这对于这个特定项目非常方便.
I've been looking a bit at protocol buffers and boost.serialize. According to the documents protocol buffers seems to care much about performance. Boost seems somewhat more lightweight in the sense that you don't have an external language for specifying the data format which I find quite convenient for this particular project.
所以我的问题归结为:有谁知道对于我上面描述的典型用例,boost 序列化是否很快?
So my question comes down to this: does anyone know if the boost serialization is fast for the typical use case I described above?
此外,如果还有其他适合此用途的库,我很乐意听到.
Also if there are other libraries that might be right for this, I'd be happy to hear about them.
推荐答案
我强烈建议使用协议缓冲区.它们使用起来非常简单,提供出色的性能,并处理字节顺序和向后兼容性等问题.为了使其更具吸引力,序列化数据与语言无关,这要归功于众多语言实现.
I would strongly suggest protocol buffers. They're incredibly simple to use, offer great performance, and take care of issues like endianness and backwards compatibility. To make it even more attractive, serialized data is language-independent thanks to numerous language implementations.
这篇关于C++ 序列化性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)