使用快速json或(select / insert)从/进入数据库更快(序列化/反序列化)? [英] which is faster(serialize/deserialize)using fast json or (select/insert)from/into database?

查看:258
本文介绍了使用快速json或(select / insert)从/进入数据库更快(序列化/反序列化)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有c#console应用程序,我想将字典的内容保存在文件或数据库中。所以我想问:

哪个更快(序列化/反序列化)使用序列化库像( fastjson)或(select / insert)from / into数据库?

I have c# console application and I want to save the content of dictionaries in a file or database.so I wanted to ask:
which is faster(serialize/deserialize)using serialization libraries like(fastjson) or (select/insert)from/into database?

推荐答案

我猜(本地)数据库应该更快。但是没有什么可以阻止你通过测量来比较实际表现(数据与你的场景兼容)。
I guess (a local) database should be faster. However nothing prevents you comparing the actual performances by measuring them (with data compatible with your scenario).


我看到你已经在评论中向Mehdi Gholam提问了一个问题他在这里关于fastJSON的文章部分;为什么不问他关于性能/内存使用的问题。



虽然我认为性能/内存使用会因你序列化的各种类型而异,您使用的数据库等。



正如Mehdi在他的文章中所述,fastJSON将处理字典;你可能会问他,包含相同类型实例的类型是否有序列化的问题...因为你使用的是树形结构。



您也可以评估用于序列化的WCF(DataContract,DataMember);我用WCF序列化了树结构。我首先将WCF序列化为内存流;然后使用Gzip压缩它,并将压缩的代码保存到磁盘。与将WCF序列化代码保存为XML相比,生成的Gzip文件几乎总是小于一半。
I see you already asked Mehdi Gholam a question in the comment section of his article on fastJSON here; why not ask him about performance/memory-use also.

Although, I think that performance/memory-use will vary depending on the various Types you are serializing, the database you use, etc.

As Mehdi states in his article, fastJSON will handle Dictionaries; you might ask him if Types that contain instances of the same Type have any problems being serialized ... since you are using a tree-structure.

You might also evaluate WCF (DataContract, DataMember) for serializing; I have serialized tree-structures with WCF. I first serialized with WCF to a memory stream; then used Gzip to compress it, and saved the compressed code to disk. The resulting Gzip file was almost always less than half the size compared to saving the WCF serialized code as XML.


这篇关于使用快速json或(select / insert)从/进入数据库更快(序列化/反序列化)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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