午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    ASP:頁(yè)面輸出太多會(huì)嚴(yán)重影響web程序的性能
    來(lái)源:易賢網(wǎng) 閱讀:590 次 日期:2014-11-01 13:14:52
    溫馨提示:易賢網(wǎng)小編為您整理了“ASP:頁(yè)面輸出太多會(huì)嚴(yán)重影響web程序的性能”,方便廣大網(wǎng)友查閱!

    數(shù)據(jù)量增加的很快,最近發(fā)現(xiàn)它的性能非常差,每次打開(kāi)都需要十幾秒,甚至幾十秒,因?yàn)槲?/P>

    的程序分頁(yè)用的是我自己的分頁(yè)程序:

    難道這個(gè)分頁(yè)程序有問(wèn)題,但是其他地方用到它沒(méi)有感覺(jué)到慢呀,我沒(méi)事就琢磨他,到網(wǎng)上查資料,結(jié)果沒(méi)有具體查到說(shuō)到我的那個(gè)分頁(yè)程序性能差的相關(guān)資料,后來(lái)我發(fā)現(xiàn)我的程序中的頁(yè)導(dǎo)航用的是數(shù)字導(dǎo)航方法,而且所有的頁(yè)導(dǎo)航的數(shù)字全都輸出來(lái)了,一共一千多頁(yè),能不能使這個(gè)地方慢呢?我決定測(cè)試一下,所以,我就只讓他輸出前200頁(yè)的導(dǎo)航鏈接,結(jié)果1秒鐘就刷出來(lái)了。這我才恍然大悟,原來(lái)是輸出內(nèi)容太多導(dǎo)致的。以前遇到性能問(wèn)題都會(huì)去想數(shù)據(jù)庫(kù)操作,從來(lái)沒(méi)有想到其他地方會(huì)不會(huì)有問(wèn)題,或很少想其他地方。其實(shí)頁(yè)面輸出的數(shù)據(jù)量對(duì)性能也是有很大影響的,所以我們一定要養(yǎng)成良好的程序書(shū)寫(xiě)習(xí)慣,力求簡(jiǎn)單。

    后來(lái)我對(duì)程序進(jìn)行了優(yōu)化,優(yōu)化分兩個(gè)步驟,第一個(gè)步驟我不將所有的導(dǎo)航都輸出來(lái),只輸出前200多頁(yè),后面再加一個(gè)文本框用于導(dǎo)航。

    同時(shí)我對(duì)每個(gè)鏈接進(jìn)行了簡(jiǎn)化,原來(lái)每個(gè)上面都有很長(zhǎng)的鏈接,至此我將鏈接放到了javascript函數(shù)中,然后再導(dǎo)航數(shù)字上只加上一個(gè)onclick事件。這樣又可以減少很多輸出數(shù)據(jù)。結(jié)果性能非常好。

    原來(lái)的代碼片斷:

    <font color="#008080" size="2">當(dāng)前<font color=ff0000>

    <%=tCurPage%></font>頁(yè) 共<font color=ff0000>

    <%=tpagecount%></font>頁(yè)

    <br><% if tTotalCount>0 then

    for i=1 to tPagecount

    %><a href='<%=request.servervariables("Path_Info")%>

    ?page=<%=i%>&browserSize=<%=browserSize%>

    &t_count=<%=tTotalCount%>&order_field=<%=tOrderField%>

    &order_dir=<%=tOrderDirection%>&oType=<%=oType%>

    &oOP=<%=oOP%>&oKey=<%=FilterParam4(oKey)%>

    &page_size=<%=tPageSize%><%=add_Option%>'><%=i%></a>

    <% if browserSize=1 then

    if i=20 or i=36 then response.write " "

    end if

    if i=fCou then

    exit for

    end if

    response.write ""

    next %>

    <%dim allStr

    if tpagecount>fCou then

    for i=fCou+1 to tpagecount

    if browserSize=0 then

    m=(i=74 or i=107 or (i>107 and ((i-107) mod 27)=0))

    else

    m=(i=94 or i=130 or (i>130 and ((i-130) mod 35)=0))

    end if

    allStr=allStr & "<a href='"&request.servervariables("Path_Info")&"?

    page="&i&"&browserSize="&browserSize&"&t_count=" & tTotalCount &

    "&order_field=" & tOrderField & "&order_dir=" & tOrderDirection & "&

    oType=" & oType & "&oOP=" & oOP & "&oKey=" & FilterParam4

    (oKey) & "&page_size=" & tPageSize & add_Option &

    "'>"

    allStr=allStr & i

    allStr=allStr & "</a>"

    if not m then allStr=allStr & " "

    if m then allStr=allStr & "<br>"

    if browserSize=1 then

    if i=58 or i=71 then allStr=allStr & " "

    end if

    if i=106 then allStr=allStr & " "

    next%>

    <script language=javascript>

    var allStr;

    allStr="<%=allStr%>";

    </script><a href="#" title="顯示更多…" id=seemore

    >

    <font color=ff0000>∨</font></a><span id=morePage></span>

    <%end if %>

    <% end if %> </font>

    更改后的代碼片斷:

    < script language="javascript">

    function mP(curPage)

    {

    try{

    if(!curPage)return false;

    var patInt=/^d+$/;

    if(!patInt.test(curPage)) return false;

    if(parseInt(curPage)<=0) return false;

    self.location='<%=request.servervariables("Path_Info")%>?

    page=' + curPage+ '&browserSize=<%=browserSize%>

    &t_count=<%=tTotalCount%>&order_field=<%=tOrderField%>

    &order_dir=<%=tOrderDirection%>&oType=<%=oType%>

    &oOP=<%=oOP%>&oKey=<%=FilterParam4(oKey)%>

    &page_size=<%=tPageSize%><%=add_Option%>';

    }

    catch(e) {

    window.status=e.description

    return false;

    }

    }

    < /script>

    <font color="#008080" size="2">當(dāng)前<font color=ff0000>

    <%=tCurPage%></font>頁(yè) 共<font color=ff0000>

    <%=tpagecount%></font>頁(yè)

    <br><% if tTotalCount>0 then

    for i=1 to tPagecount

    %><span ><%=i%></span>

    <% if browserSize=1 then

    if i=20 or i=36 then response.write " "

    end if

    if i=fCou then

    exit for

    end if

    response.write ""

    next

    dim allStr

    if tpagecount>fCou then

    showPageCount=tpagecount

    if showPageCount>260 then showPageCount=260

    for i=fCou+1 to showPageCount

    if browserSize=0 then

    m=(i=74 or i=107 or (i>107 and ((i-107) mod 27)=0))

    else

    m=(i=94 or i=130 or (i>130 and ((i-130) mod 35)=0))

    end if

    allStr=allStr & "<span >GO</span>"%><a href="#" title="顯示更多…"

    id=seemore ><font color=ff0000>∨</font></a>

    <span id=morePage style="display:none"><%=allStr%></span>

    <%end if

    end if

    %> </font>

    更多信息請(qǐng)查看IT技術(shù)專欄

    更多信息請(qǐng)查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機(jī)網(wǎng)站地址:ASP:頁(yè)面輸出太多會(huì)嚴(yán)重影響web程序的性能
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門(mén)公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2025國(guó)考·省考課程試聽(tīng)報(bào)名

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)