运行这个页面CPU占用一开始就达到20%,内存也会慢慢增加,sieve测试每请求一次dom节点会增加40个..请问有什么优化方案?或者解决这个问题的方案吗?
3Q
代码如下..<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TradeShow1.aspx.cs" Inherits="TankManage_TradeShow1"
UICulture="en" %><%Response.Expires = 0; %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="../Style/Trade.css" rel="stylesheet" type="text/css" />
<script src="../Js/jquery-1.4.2.min.js" type="text/javascript"></script>
</head>
<body style="background-color: #deecf9;">
<form id="form1" runat="server">
<input id="status" type="hidden" runat="server" />
<div style="padding-top: 3px;">
<div id="Show" style="background-color: #deecf9; padding: 0px; margin: 0px; height: auto;">
<div id="data" style="width: 2600px; border: solid 1px #deecf9; text-align: left;
margin-top: -2px; padding-left: 3px;">
<div id="head" style="width: 2600px; text-align: left;">
<asp:Label ID="WPID" class="b" runat="server" Text="序号"></asp:Label>
<asp:Label ID="NZN" class="b" runat="server" Text="枪号"></asp:Label>
<asp:Label ID="OilName" class="e" runat="server" Text="油品名称"></asp:Label>
<asp:Label ID="V_TOT" class="d" runat="server" Text="升累计"></asp:Label>
<asp:Label ID="AMN" class="d" runat="server" Text="数额"></asp:Label>
<asp:Label ID="VOL" class="d" runat="server" Text="升数"></asp:Label>
<asp:Label ID="PRC" class="c" runat="server" Text="成交价格"></asp:Label>
<asp:Label ID="T_TYPE" class="c" runat="server" Text="交易类型"></asp:Label>
<asp:Label ID="POS_TTC" class="d" runat="server" Text="交易记录号"></asp:Label>
<asp:Label ID="ASN" class="g" runat="server" Text="卡应用号"></asp:Label>
<asp:Label ID="BAL" class="e" runat="server" Text="余额"></asp:Label>
<asp:Label ID="UNIT1" class="c" runat="server" Text="结算单位"></asp:Label>
<asp:Label ID="UNIT2" class="c" runat="server" Text="结算方式"></asp:Label>
<asp:Label ID="TAC" class="e" runat="server" Text="电子签名"></asp:Label>
<asp:Label ID="CTC" class="b" runat="server" Text="CTC"></asp:Label>
<asp:Label ID="InTIME" class="f" runat="server" Text="PC机时间"></asp:Label>
<asp:Label ID="TIME" class="f" runat="server" Text="油机时间"></asp:Label>
<asp:Label ID="EMP" class="b" runat="server" Text="员工号"></asp:Label>
<asp:Label ID="VER" class="b" runat="server" Text="版本"></asp:Label>
<asp:Label ID="GMAC" class="d" runat="server" Text="解灰认证码"></asp:Label>
<asp:Label ID="DS" class="e" runat="server" Text="扣款来源"></asp:Label>
<asp:Label ID="C_TYPE" class="e" runat="server" Text="卡类型"></asp:Label>
<asp:Label ID="PSAM_TAC" class="d" runat="server" Text="灰锁签名"></asp:Label>
<asp:Label ID="PSAM_ASN" class="g" runat="server" Text="PSAM应用号"></asp:Label>
<asp:Label ID="PSAM_TID" class="e" runat="server" Text="PSAM编号"></asp:Label>
<asp:Label ID="PSAM_TTC" class="d" runat="server" Text="PSAM-TTC"></asp:Label>
<asp:Label ID="T_MAC" class="h" runat="server" Text="终端数据认证码"></asp:Label>
</div>
</div>
<div id="ShowData" style="width: 2600px;">
</div>
</div>
</div>
<script type="text/javascript">
var clearData;
window.clearInterval(clearData);
clearData = window.setInterval('bind()', 1000);
var row;
function bind() {
$.getJSON("TradeData1.aspx", function(data) {
var j = $("#ShowData");
$("#ShowData")[0].innerHTML = "";
$.each(data, function(index, item) { //index为索引,item为对象
row = $("#data").clone();
row.find("#WPID").text(index + 1);
row.find("#NZN").text(item['NZN']);
row.find("#G_CODE").text(item['G_CODE']);
row.find("#BAL").text(item['BAL']);
row.find("#AMN").text(item['AMN']);
row.find("#CTC").text(item['CTC']);
row.find("#TAC").text(item['TAC']);
row.find("#GMAC").text(item['GMAC']);
row.find("#PSAM_TAC").text(item['PSAM_TAC']);
row.find("#PSAM_TID").text(item['PSAM_TID']);
row.find("#PSAM_ASN").text(item['PSAM_ASN']);
row.find("#UNIT1").text(item['UNIT1']);
row.find("#UNIT2").text(item['UNIT2']);
row.find("#PSAM_TTC").text(item['PSAM_TTC']);
row.find("#DS").text(item['DS']);
row.find("#C_TYPE").text(item['C_TYPE']);
row.find("#VER").text(item['VER']);
row.find("#ASN").text(item['ASN']);
row.find("#TIME").text(item['TIME']);
row.find("#VOL").text(item['VOL']);
row.find("#PRC").text(item['PRC']);
row.find("#EMP").text(item['EMP']);
row.find("#V_TOT").text(item['V_TOT']);
row.find("#RFU").text(item['RFU']);
row.find("#T_MAC").text(item['T_MAC']);
row.find("#OilName").text(item['OilName']);
row.find("#InTIME").text(item['InTIME']);
row.find("#POS_TTC").text(item['POS_TTC']);
row.find("#T_TYPE").text(item['T_TYPE']);
row.appendTo("#ShowData"); //添加到模板的容器中
});
row="";
});
}
</script>
</form>
</body>
</html>
3Q
代码如下..<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TradeShow1.aspx.cs" Inherits="TankManage_TradeShow1"
UICulture="en" %><%Response.Expires = 0; %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<link href="../Style/Trade.css" rel="stylesheet" type="text/css" />
<script src="../Js/jquery-1.4.2.min.js" type="text/javascript"></script>
</head>
<body style="background-color: #deecf9;">
<form id="form1" runat="server">
<input id="status" type="hidden" runat="server" />
<div style="padding-top: 3px;">
<div id="Show" style="background-color: #deecf9; padding: 0px; margin: 0px; height: auto;">
<div id="data" style="width: 2600px; border: solid 1px #deecf9; text-align: left;
margin-top: -2px; padding-left: 3px;">
<div id="head" style="width: 2600px; text-align: left;">
<asp:Label ID="WPID" class="b" runat="server" Text="序号"></asp:Label>
<asp:Label ID="NZN" class="b" runat="server" Text="枪号"></asp:Label>
<asp:Label ID="OilName" class="e" runat="server" Text="油品名称"></asp:Label>
<asp:Label ID="V_TOT" class="d" runat="server" Text="升累计"></asp:Label>
<asp:Label ID="AMN" class="d" runat="server" Text="数额"></asp:Label>
<asp:Label ID="VOL" class="d" runat="server" Text="升数"></asp:Label>
<asp:Label ID="PRC" class="c" runat="server" Text="成交价格"></asp:Label>
<asp:Label ID="T_TYPE" class="c" runat="server" Text="交易类型"></asp:Label>
<asp:Label ID="POS_TTC" class="d" runat="server" Text="交易记录号"></asp:Label>
<asp:Label ID="ASN" class="g" runat="server" Text="卡应用号"></asp:Label>
<asp:Label ID="BAL" class="e" runat="server" Text="余额"></asp:Label>
<asp:Label ID="UNIT1" class="c" runat="server" Text="结算单位"></asp:Label>
<asp:Label ID="UNIT2" class="c" runat="server" Text="结算方式"></asp:Label>
<asp:Label ID="TAC" class="e" runat="server" Text="电子签名"></asp:Label>
<asp:Label ID="CTC" class="b" runat="server" Text="CTC"></asp:Label>
<asp:Label ID="InTIME" class="f" runat="server" Text="PC机时间"></asp:Label>
<asp:Label ID="TIME" class="f" runat="server" Text="油机时间"></asp:Label>
<asp:Label ID="EMP" class="b" runat="server" Text="员工号"></asp:Label>
<asp:Label ID="VER" class="b" runat="server" Text="版本"></asp:Label>
<asp:Label ID="GMAC" class="d" runat="server" Text="解灰认证码"></asp:Label>
<asp:Label ID="DS" class="e" runat="server" Text="扣款来源"></asp:Label>
<asp:Label ID="C_TYPE" class="e" runat="server" Text="卡类型"></asp:Label>
<asp:Label ID="PSAM_TAC" class="d" runat="server" Text="灰锁签名"></asp:Label>
<asp:Label ID="PSAM_ASN" class="g" runat="server" Text="PSAM应用号"></asp:Label>
<asp:Label ID="PSAM_TID" class="e" runat="server" Text="PSAM编号"></asp:Label>
<asp:Label ID="PSAM_TTC" class="d" runat="server" Text="PSAM-TTC"></asp:Label>
<asp:Label ID="T_MAC" class="h" runat="server" Text="终端数据认证码"></asp:Label>
</div>
</div>
<div id="ShowData" style="width: 2600px;">
</div>
</div>
</div>
<script type="text/javascript">
var clearData;
window.clearInterval(clearData);
clearData = window.setInterval('bind()', 1000);
var row;
function bind() {
$.getJSON("TradeData1.aspx", function(data) {
var j = $("#ShowData");
$("#ShowData")[0].innerHTML = "";
$.each(data, function(index, item) { //index为索引,item为对象
row = $("#data").clone();
row.find("#WPID").text(index + 1);
row.find("#NZN").text(item['NZN']);
row.find("#G_CODE").text(item['G_CODE']);
row.find("#BAL").text(item['BAL']);
row.find("#AMN").text(item['AMN']);
row.find("#CTC").text(item['CTC']);
row.find("#TAC").text(item['TAC']);
row.find("#GMAC").text(item['GMAC']);
row.find("#PSAM_TAC").text(item['PSAM_TAC']);
row.find("#PSAM_TID").text(item['PSAM_TID']);
row.find("#PSAM_ASN").text(item['PSAM_ASN']);
row.find("#UNIT1").text(item['UNIT1']);
row.find("#UNIT2").text(item['UNIT2']);
row.find("#PSAM_TTC").text(item['PSAM_TTC']);
row.find("#DS").text(item['DS']);
row.find("#C_TYPE").text(item['C_TYPE']);
row.find("#VER").text(item['VER']);
row.find("#ASN").text(item['ASN']);
row.find("#TIME").text(item['TIME']);
row.find("#VOL").text(item['VOL']);
row.find("#PRC").text(item['PRC']);
row.find("#EMP").text(item['EMP']);
row.find("#V_TOT").text(item['V_TOT']);
row.find("#RFU").text(item['RFU']);
row.find("#T_MAC").text(item['T_MAC']);
row.find("#OilName").text(item['OilName']);
row.find("#InTIME").text(item['InTIME']);
row.find("#POS_TTC").text(item['POS_TTC']);
row.find("#T_TYPE").text(item['T_TYPE']);
row.appendTo("#ShowData"); //添加到模板的容器中
});
row="";
});
}
</script>
</form>
</body>
</html>
别用这么多label啊!改成html的
你这个关闭不了。每1秒钟就执行一次bind()函数
应该在进行数据的读取操作,加上你每隔一秒就进行操作,消耗的资源比较高