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

推荐订阅源

The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
T
Threatpost
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
PCI Perspectives
PCI Perspectives
T
The Exploit Database - CXSecurity.com
Y
Y Combinator Blog
雷峰网
雷峰网
爱范儿
爱范儿
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
S
Securelist
宝玉的分享
宝玉的分享
L
LangChain Blog
O
OpenAI News
AI
AI
P
Privacy International News Feed
L
LINUX DO - 最新话题
D
DataBreaches.Net
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs
罗磊的独立博客
M
MIT News - Artificial intelligence
Security Archives - TechRepublic
Security Archives - TechRepublic
月光博客
月光博客
博客园 - 【当耐特】
T
Tailwind CSS Blog
C
Cybersecurity and Infrastructure Security Agency CISA
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
Jina AI
Jina AI
The Last Watchdog
The Last Watchdog
K
Kaspersky official blog
Webroot Blog
Webroot Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Blog — PlanetScale
Blog — PlanetScale
MyScale Blog
MyScale Blog
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 三生石上(FineUI控件)
The Cloudflare Blog

博客园 - 范文轩

Sharepoint中的Feature Stapling功能 SharePoint 2010中的WebProvisioned Event Handler 如何向列表中添加数据值(开发篇补充REST) 如何向列表中添加数据值(开发篇) 如何向列表中添加数据值(管理员篇) 在SharePoint 2010中动态加载Visio Web Part 使用编程的方式来启动SharePoint的工作流 InfoPath 2010调用REST的一个小应用 SharePoint 2010 WSP包部署过程中究竟发生什么? 如何查看SharePoint 2010的CU版本 SharePoint 2010多语言包的安装 在SharePoint 2010中使用Linq时候,请注意特殊字符 自定义ASP.NET WebApplication中调用SharePoint2010的对象 在Infopath 2010中调用Web Service 给Document Set里面添加文件夹 给Chart Web Part 添加过滤功能 SharePoint 2010的Form认证的用户注册功能 SharePoint 调查列表的自定义错误页面 Reporting Services 2008 and SharePoint 2010
谈谈SharePoint 2010的客户端对象模型的性能问题
范文轩 · 2011-02-06 · via 博客园 - 范文轩

声明:本文是我阅读了Steve Peschka的一些列文章之后的一些感受。如果你对客户端对象模型感兴趣,那么建议你读一下这一些列文章http://blogs.technet.com/b/speschka/archive/2009/11/01/using-the-sharepoint-2010-client-object-model-part-1.aspx 

影响SharePoint 的客户端对象模型很重要的两个因素是:传递数据量的大小,以及与服务器来回传递数据(Roundtrips)的次数,我这里将借助Fiddler(http://www.fiddler2.com/fiddler2/) 工具对此进行说明。

例子1:使用对象模型获取当前站点所有的列表的标题。

之前:

 public void QueryAllList()
        {
            Web web = ctx.Web;
            var lists = ctx.LoadQuery(web.Lists);
            ctx.ExecuteQuery();
            foreach (List lst in lists)
            {
                Console.WriteLine("Title:{0}",
                    lst.Title);
            }
        }

Fiddler数据:

image

之后:

public void QueryAllList()
        {
            Web web = ctx.Web;
            var lists = ctx.LoadQuery(web.Lists.Include(
                lst=>lst.Title));
            ctx.ExecuteQuery();
            foreach (List lst in lists)
            {
                Console.WriteLine("Title:{0}",
                    lst.Title);
            }
        }

Fiddler数据

image

对比:

  之前 之后
Request Count: 4 4
Bytes Sent: 3.294 3.353
Bytes Received: 81.989 14.526
Sequence (clock) time (s) 1.357 0.936

例子二:获取当前站点的所有组(ID属性),以及组内的用户(用户的Title属性)。

之前:

public void GetAllUsersInGroups()
        {
            ctx.Load(ctx.Web.SiteGroups);
            ctx.ExecuteQuery();

            foreach (Group currentGroup in ctx.Web.SiteGroups)
            {
                ctx.Load(currentGroup);
                ctx.ExecuteQuery();
                try
                {
                    ctx.Load(currentGroup.Users);
                    ctx.ExecuteQuery();
                    foreach (User currentUser in currentGroup.Users)
                    {
                        Console.WriteLine(currentGroup.Id + "--" + currentUser.Title);                       
                    }
                }
                catch { };
            }
        }

Fiddler数据:

image

之后:

 public void GetAllUsersInGroups()
        {
            ctx.Load(ctx.Web.SiteGroups,
                grps => grps.Include(
                    grp => grp.Id,
                    grp => grp.Users.Include(usr => usr.Title)));

            ctx.ExecuteQuery();

            foreach (Group currentGroup in ctx.Web.SiteGroups)
            {
                foreach (User usr in currentGroup.Users)
                {
                    Console.WriteLine(currentGroup.Id + "--" + usr.Title);
                }
            }
        }

Fiddler数据:

image

对比:

  之前 之后
Request Count: 32 4
Bytes Sent: 37.441 3.379
Bytes Received: 38.065 8.119
Sequence (clock) time (s) 2.204 0.956

结论:当你使用SharePoint 客户端对象模型的时候:

1. 只查询你需要的数据,或者列;

2. 尽量减少与服务器之间来回传递(Roundtrips)数据的次数。