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

推荐订阅源

M
MIT News - Artificial intelligence
博客园 - Franky
H
Help Net Security
A
About on SuperTechFans
Know Your Adversary
Know Your Adversary
罗磊的独立博客
Help Net Security
Help Net Security
腾讯CDC
博客园 - 三生石上(FineUI控件)
月光博客
月光博客
Project Zero
Project Zero
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
T
Threat Research - Cisco Blogs
The Hacker News
The Hacker News
Engineering at Meta
Engineering at Meta
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
T
Threatpost
Google DeepMind News
Google DeepMind News
V
V2EX
B
Blog
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
N
Netflix TechBlog - Medium
P
Privacy International News Feed
Recorded Future
Recorded Future
D
Darknet – Hacking Tools, Hacker News & Cyber Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Stack Overflow Blog
Stack Overflow Blog
Cisco Talos Blog
Cisco Talos Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Securelist
NISL@THU
NISL@THU
The GitHub Blog
The GitHub Blog
T
Troy Hunt's Blog
S
Security @ Cisco Blogs
Vercel News
Vercel News
L
LINUX DO - 热门话题
博客园_首页
The Register - Security
The Register - Security
GbyAI
GbyAI
TaoSecurity Blog
TaoSecurity Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
V2EX - 技术
V2EX - 技术
L
LangChain Blog
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Security Latest
Security Latest
K
Kaspersky official blog

博客园 - 天天无用

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/,请自行下载