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

推荐订阅源

S
Securelist
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
Hacker News: Ask HN
Hacker News: Ask HN
L
Lohrmann on Cybersecurity
PCI Perspectives
PCI Perspectives
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cyber Attacks, Cyber Crime and Cyber Security
Recent Commits to openclaw:main
Recent Commits to openclaw:main
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog
月光博客
月光博客
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
The GitHub Blog
The GitHub Blog
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
TaoSecurity Blog
TaoSecurity Blog
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
F
Full Disclosure
U
Unit 42
Jina AI
Jina AI
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
大猫的无限游戏
大猫的无限游戏
The Hacker News
The Hacker News
The Last Watchdog
The Last Watchdog
T
Troy Hunt's Blog
腾讯CDC
T
Threatpost
H
Hacker News: Front Page
P
Palo Alto Networks Blog
博客园 - 聂微东
Last Week in AI
Last Week in AI
有赞技术团队
有赞技术团队
Help Net Security
Help Net Security
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Spread Privacy
Spread Privacy

博客园 - 涛仔28

Unreal Engine Plugin management HYPE若干经验 转 ifstream 读取中文路径 总结SQLExpress2008安装 如何使用子程序参数--摘自代码大全2 WinDBG咒语 SunFlow渲染流程的设计 SunFlow场景文件的Instances代码块摘要 SunFlow场景文件的GI代码块摘要 SunFlow场景文件的Cameras代码块摘要 SunFlow场景文件的Object代码块 SunFlow场景文件的Modifiers代码块 - 涛仔28 - 博客园 SunFlow场景文件的Shader代码块 - 涛仔28 - 博客园 SunFlow场景文件的Light代码块 SunFlow场景文件的Image代码块 SunFlow场景文件的代码顺序 关于Ext3.0释出 函数的连续性 脚本的杂乱思路
关于JSON的大文本处理
涛仔28 · 2007-12-22 · via 博客园 - 涛仔28

JSON在处理大文本数据的时候存在严重的效率问题,反序列化的时候CPU占用率甚至可以达到80%,
找到个处理办法是在客户端就拆成小片段,到服务器再组装起来,如下:

 1//大文本优化
 2                var originContent = article.Content;                
 3                var contentLen = originContent.length;
 4                if(contentLen > 1000){
 5                    article.Content = '';        //clear it!!!
 6                    var len = Math.ceil(contentLen / 1000);
 7                    var splitContent = [];
 8                    for(var i=0;i < len; i++){
 9                        var start = i*1000;
10                        var end = start + 1000;
11                        if(end > contentLen-1) end = contentLen -1;
12                        splitContent.push(originContent.substring(start,end));
13                    }

14                    article.ContentSegments = splitContent;
15                }

然后在服务器端组装起来:

 1if(article.Content.Length == 0)
 2            {
 3                if(article.ContentSegments != null && article.ContentSegments.Count > 0)
 4                {
 5                    StringBuilder buf = new StringBuilder();
 6                    foreach (string s in article.ContentSegments)
 7                    {
 8                        buf.Append(s);
 9                    }

10                    article.Content = buf.ToString();
11                }

12            }