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

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
WordPress大学
WordPress大学
Vercel News
Vercel News
Apple Machine Learning Research
Apple Machine Learning Research
T
Tailwind CSS Blog
I
InfoQ
小众软件
小众软件
Recent Announcements
Recent Announcements
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
美团技术团队
T
The Blog of Author Tim Ferriss
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
MongoDB | Blog
MongoDB | Blog
V
V2EX
J
Java Code Geeks
有赞技术团队
有赞技术团队
博客园 - 聂微东
B
Blog RSS Feed
博客园 - 司徒正美

博客园 - 范文轩

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)数据的次数。