惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
MyScale Blog
MyScale Blog
WordPress大学
WordPress大学
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
MongoDB | Blog
MongoDB | Blog
V
Vulnerabilities – Threatpost
月光博客
月光博客
罗磊的独立博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Apple Machine Learning Research
Apple Machine Learning Research
有赞技术团队
有赞技术团队
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
F
Full Disclosure
Simon Willison's Weblog
Simon Willison's Weblog
D
DataBreaches.Net
T
Threatpost
Hacker News: Ask HN
Hacker News: Ask HN
阮一峰的网络日志
阮一峰的网络日志
TaoSecurity Blog
TaoSecurity Blog
Microsoft Azure Blog
Microsoft Azure Blog
Scott Helme
Scott Helme
S
Securelist
W
WeLiveSecurity
K
Kaspersky official blog
The GitHub Blog
The GitHub Blog
Attack and Defense Labs
Attack and Defense Labs
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
Google Online Security Blog
Google Online Security Blog
Stack Overflow Blog
Stack Overflow Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Security Latest
Security Latest
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
The Last Watchdog
The Last Watchdog
C
Check Point Blog
T
Troy Hunt's Blog
P
Proofpoint News Feed
J
Java Code Geeks
G
Google Developers Blog
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
S
Security @ Cisco Blogs
宝玉的分享
宝玉的分享
Recent Commits to openclaw:main
Recent Commits to openclaw:main
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
L
LINUX DO - 最新话题
Jina AI
Jina AI

博客园 - 天天无用

jsonp原理实例及mvc中的应用 ubuntu笔记 修复MVC3中使用Remote验证的一点小问题 诺基亚手机S60系统证书申请、软件签名图文教程 JAXER留言板-一个html页面的ajax留言版 - 天天无用 - 博客园 初探JAXER Jquery插件研究:Ajax File Upload 本月wii游戏太多,感觉有点堕落 使用jQuery加DIV实现可以动态添加的金字塔结构 自制的操作下拉列表框(SELECT)的三个jquery插件(ajax填充、联动、增加选项) - 天天无用 - 博客园 Asp.net 2.0 TreeView控件使用jQuery无刷新添加节点详细说明 用jQuery实现.net 2.0 treeview客户端无刷新操作的实例 基于jQuery的AJAX和JSON实现纯html数据模板 自己写的DataTable转换成JSON字符串的函数 自己写的jQuery自动完成的插件(AutoComplete) asp.net treeview控件无刷新选择和删除节点(使用jquery) - 天天无用 - 博客园 纵向合并gridview单元格的两种方法 asp.net 2.0 中 TreeView控件中的checkbox客户端操作 asp.net 2.0中根据roles显示不同的sitemap - 天天无用 - 博客园
.net下两种json序列化速度比对
天天无用 · 2007-11-14 · via 博客园 - 天天无用

最近研究JSON,想把datatable直接序列化为json,上网查了查,发现.net下有这么两种json序列化的方法:

 一是用Newtonsoft.Json.dll进行json序列化,这个从json的官网上就可以找到,使用比较方便。

二是用xml-2-json.xsl这个xslt模板转换,详细请看这里http://blog.csdn.net/isaaq/archive/2006/12/09/1436357.aspx

两种序列话方法都可以达到要求,但是我想看一下两种分别的速度如何,于是自己写个程序试一下。

生成datatable的代码如下 


其中循环次数分别是10,100,1000,1000,然后看一下两种方法的序列话速度。结果见下表

  JSON.DLL XSLT
10 0毫秒 31.25毫秒
100 15.625毫秒 31.25毫秒
1000 46.875毫秒 140.625毫秒
10000 9531.25毫秒 31218.75毫秒

程序写的并不严谨,只是简单比对一下速度而已,数据都是多次运行取的相当稳定的值而已,并不能说明具体时间。有一个奇怪的现象是,循环次数为10000时,用XSLT转换一般都是30秒左右,但有时会有10秒左右的现象出现,不知是什么原因。

有需要源代码的朋友请留下邮箱,我会尽快发过去的。另外想请大家帮忙看一下我用json.dll序列化datatable的方法是否正确,我是把datatable转换为xml,然后用json.dll转换xml为json,不知道有没有更好的方法,谢谢大家。

源代码已经上传到http://download.csdn.net/user/luq885/,请自行下载