在哪里对集合进行排序会更快 - 客户端还是服务器端?
我有一个关于客户端与服务器端处理的问题。
我有一个相当大的对象集合(假设是一个由日常字段组成的“用户”对象集合 - name
、last name
、age
,isAdmin
等...)
现在,我想将这个大集合分成两个小集合,其中谓词是一个布尔字段 - isAdmin
- 它告诉我们是否用户是否是管理员。
分离后,我需要将两个最终集合发送到服务器端进行一些更复杂的处理。
我想知道在客户端进行排序和拆分会更有效(也许使用 Javascript 或 jQuery?它会起作用吗?)或者只是将大集合发送到服务器并让它处理所有内容(都拆分)使用 LINQ 和进一步处理)。
一般来说,在什么情况下使用客户端比使用服务器端更好?为什么?
I have a question concerning client side vs. server side processing.
I have a rather big collection of objects (lets say a collection of "user" objects which consists of everyday fields - name
, last name
, age
, isAdmin
etc...)
Now, I want to separate this big collection into two small collections where the predicate is a boolean field - isAdmin
- which tells us if the user is an admin or not.
After the separation I will need to send both final collections to the server side for some more complex processing.
I was wondering where it will be more efficient to do the sorting and spliting in the client side (using Javascript or jQuery perhaps? would it do the trick?) or just send the big collection to the server and let it handle everything (both splitting using LINQ and further processing).
And generally, in which cases is it better to use client side over server side? and why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
与往常一样,性能问题通常很难回答,因此它取决于:
你确实需要做一些测试才能解决这个问题。即便如此,由于每个用户都可能使用不同的计算机,因此对于我来说,2001 年老式硬件上的答案可能与使用 2011 年四核(16GB 内存和最高效的 JavaScript 解释器)的人不同。
As always, performance questions are hard to answer in general, so it depends on:
You'd really have to do some testing to figure this one out. Even then, because every user could be on a different computer, the answer might be different for me on my 2001-vintage hardware compared to somebody with a 2011 quad-core with 16GB of memory and the most efficient javascript interpreter.
这个问题确实没有简单的答案,因为有很多变量在起作用,例如:
……可能还有很多其他东西。
过去我们可以说服务器总是比客户端更快,但由于强大计算的高可用性和应用程序托管的商品化,这种情况不再一定是这样了。
但除了速度之外,还有其他事情需要考虑,比如安全性。如果您的 User 对象包含敏感信息,您真的希望信任客户端计算机拥有该数据吗?
There is really no simple answer to this, as there are a lot of variables at play such as:
... and probably a bunch of other things.
It used to be the case that we could say that the server was always faster than the client, but that isn't necessarily true anymore because of the high availability of powerful computing and the commoditization of application hosting.
But besides speed, there are other things to consider, such as security. If your User object contains sensitive information, do you really want to trust a client's computer with that data?