性能出了点问题 [英] something wrong with performance

查看:85
本文介绍了性能出了点问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery,nockout和WCF.我正在通过Ajax请求加载来自WCF的数据,并将数据推入可观察的数组.这个可观察的数组绑定到html表

I am using jquery,knockout and WCF. I am loading data coming from WCF via Ajax request and push data into observable array. This observable array is binded to html table

<div  style="overflow: hidden;" >
<table style="width: 100%" >
    <thead>
        <tr>
            <th>Id </th>
            <th>Name</th>
        </tr>
    </thead>
</table>
<div style="overflow: auto;height: 320px;">
    <table id ="Table1" style="width: 100%;" >
        <tbody data-bind="foreach: ListOfArray">
            <tr  data-bind= "click: showData">
                <td data-bind="text: Id"></td>
                <td  data-bind="text: Name "></td>
            </tr>   
        </tbody>
    </table>
</div>

当我单击行时,它需要4-5秒才能选择它.当我点击行时,我放了探查器.这就是它的显示

When i click on row then it takes 4-5 seconds to select it. I put profiler when i click on row. This is what it shows

有人可以指点我在哪里放慢速度,为什么?

Can someone point me where is it slowing down and why?

推荐答案

从您的评论中可以看出,当性能较差时,HTML表将显示"5000行" 如果只有200行,性能会很好."

From your comments you have said your HTML table is displaying "5000 rows" when performance is poor but "performace is good if just have 200 rows".

通常,由于内存限制和所发现的性能影响,应用程序不应尝试显示大量项目(在这种情况下为5000).

Generally an app should not attempt to display a large number of items (in this case 5000) due to memory limitations and the impact on performance as you have discovered.

最常见的做法是只进行分页,并一次显示20个项目,且同时显示上一个下一个页码.

The most common practice is to just do paging and show say 20 items at a time complete with Previous; Next and page numbers.

如果您不希望分页,可以将表重新设计为虚拟表,实际上,您可以对表进行表示的数量没有限制(仅虚拟视图)加载到内存中可以看到的内容不能什么是屏幕外).感谢在 Facebook 上无休止的滚动.

An alternative approach if you don't want paging is to redesign your table to be a virtual table where you essentially there is no limit on the number of items that could be represented (virtual views only load into memory what can be seen and not what is off-screen). Thank the endless scrolling on Facebook.

这篇关于性能出了点问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆