473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Perf prob with IE

Raj
Hello all:

We have a table with about 2400 cells. Our requirement is to highlight
the cells in the table whose data has changed, every 5 seconds. Our
script behaves relatively ok in Firefox, but the performance in IE
really bad. Have attached a simple html which simulates the prob. Any
inputs on how to improve the perf in IE are greatly appreciated.

Thanks,
Raj
---
<HTML>
<HEAD>
<style>
.normal_td { background-color: #DDDDDD }
.red_td { background-color: #FF0000 }
.blue_td { background-color: #0000FF }
</style>
<script language="JavaScript1.2">
var kk=100;

function updateTableCells()
{
var tbl = document.getElementById("tbl");
var tds = tbl.getElementsByTagName("td");

for(var k=0; k<tds.length;k++)
{
tds[k].firstChild.nodeValue = kk;
var rem = kk-(parseInt(kk/7)*7);

if(rem == 0)
setClassName(tds[k], "red_td");
else if(rem==5)
setClassName(tds[k], "normal_td");
else if(rem==2)
setClassName(tds[k], "blue_td");
else
setClassName(tds[k], null);
kk++;
if(kk>10000)kk=5000;
}
}

function setClassName(n, name){
if(n.className!=name)
n.className=name;
}

function init(){
var str="<table id='tbl'>";
for (var i=0;i<150;i++)
{
str+="<tr>\n";
for (var j=0;j<16;j++)
{
str+="<td id='ele"+i+"_"+j+"'>"+j+"</td>\n";
}
str+="</tr>\n";
}
str +="</table>";
var bod = document.getElementById("bod");
bod.innerHTML=str;
setInterval('updateTableCells()','5000');
}

window.onload = init;
</script>
</HEAD>
<BODY id="bod"/>
</HTML>
Jul 23 '05 #1
15 1537
Raj wrote on 06 dec 2004 in comp.lang.javascript:
We have a table with about 2400 cells. Our requirement is to highlight
the cells in the table whose data has changed, every 5 seconds. Our
script behaves relatively ok in Firefox, but the performance in IE
really bad. Have attached a simple html which simulates the prob. Any
inputs on how to improve the perf in IE are greatly appreciated.


<td>s do not change by themselves,
but if you mean by "changed" <input>s changed by the user,
try for IE:

input { background-color:expression(value!=defaultValue?"cyan":"");}

I don't know the performance loss of the expression() syntax with such an
silly large number of <input>s
Jul 23 '05 #2
Hi Evertjan:

Every 5 secs fresh data is downloaded from the server. The downloaded
data is compared against the data currently being displayed in the
table. If any of the cells have changed, the javascript updates the
value of the cell and changes the cell color based on whether the
change is positive or negative from the previous value.

Jul 23 '05 #3


Only 2400? :0

http://www.peachpit.com/articles/article.asp?p=31567

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #4


Just a thought: why not have the server determine this, and return a
(DOM-oriented) JS which does the highlighting?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5
VK
IE doesn't use DOM for tables, it uses its proprietary TOM.
The DOM's childhead in this case is just a mimic interface atop of TOM (to
keep 3W happy).

(1) So the first major "perf" improvement you are getting by working
directly with TOM:

if (navigator.appName.indexOf('Microsoft')! =-1) {
/* a sample iteration thru all cells,
presuming you have only one <tbody> tag: */
var oBody = document.getElementById(tableID).tbodies[0];
for (i=0;oBody.rows.length;i++) {
for (j=0;oBody.rows[i].cells.length;i++) {
if (oBody.rows[i].cells[j] == myCriteria) {
/* Or: oBody.rows[i].cells[j].innerHTML == myCriteria */
/* (2) The runtime style class reassignments seems very academically
profound,
but it's VERY resource consuming.
You are saving A LOT by using runtimeStyle object,
and by changing only properties you need to change */
oBody.rows[i].cells[j].runtimeStyle.backgroundColor = highlightColor;
}
}
}
}

(3) If you are getting data updates from the server, then the server knows
what cells have been changed. So instead of making your script behave like a
tiger in the cage, looping every time thru all cells, you could receive
{i,j} indexes of updated cells directly from your server.

(4) Actually all this structure is "screaming" for data binding, this would
give you the "max perf".


Jul 23 '05 #6
Hello Rob,

Doing the checks on the server side would be scalability issue. It
would be better if we could utilize the client CPUs for rendering.

Jul 23 '05 #7
wrote on 06 dec 2004 in comp.lang.javascript:
Every 5 secs fresh data is downloaded from the server. The downloaded
data is compared against the data currently being displayed in the
table. If any of the cells have changed, the javascript updates the
value of the cell and changes the cell color based on whether the
change is positive or negative from the previous value.


This is not email. Your answer is read by many, so PLEASE quote a relevant
part of the original. Follow usenet netiquette.

==================

Downloaded to a HTML table, how, why?

Then you loose the original table cell content, I suppose.

I suggest you do such comparing on the server, not on the client browser.

Evertjan.

Jul 23 '05 #8
VK wrote:
IE doesn't use DOM for tables, it uses its proprietary TOM.
The DOM's childhead in this case is just a mimic interface atop of TOM (to
keep 3W happy).

(1) So the first major "perf" improvement you are getting by working
directly with TOM:

if (navigator.appName.indexOf('Microsoft')! =-1) {


<--snip-->

And you have just introduced a very unreliable method into your script.
Namely, by trying to identify the browser based on the navigator object.
A better solution is to test for the actual object/properties you want
to use. The c.l.j FAQ covers it.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #9
>> Every 5 secs fresh data is downloaded from the server. The
downloaded
data is compared against the data currently being displayed in the
table. If any of the cells have changed, the javascript updates the
value of the cell and changes the cell color based on whether the
change is positive or negative from the previous value.

This is not email. Your answer is read by many, so PLEASE quote a relevantpart of the original. Follow usenet netiquette.
I am using http://groups.google.com which has pretty much gmail like
threaded view, so didnt realize the problems other face. Will
copy+paste the relevant parts ... sorry and thanks.
Downloaded to a HTML table, how, why?
Then you loose the original table cell content, I suppose.
I suggest you do such comparing on the server, not on the client

browser.

Ok ... let me try to elaborate on the problem. The application shows
the prices of stocks being traded in a web page. When a user logs in to
the application, they can select the stocks they are interested in.
They are then taken to a page which shows the price [and other details]
of the stocks in the form of a table. Every 5 secs there is a script
which downloads the new price list [in csv format] and updates the
cells which have changed. The background colour of the cell is changed
based on whether the new value of the cell is more/less than the
current value.

We did consider forming the HTML [with new background colours] on the
server side. This increases the CPU load on the server side. The
current model uses client side CPU to do the rendering and it works
fine in case of the rich client and incase of firefox browser. The
problem is only with IE. Once the page is loaded in IE, it takes 100%
CPU for couple of mins and then drops for a sec or so and then it takes
off again.

I donot think it is a problem with changing the style of the cells.
Just updating the cell values takes up a whole lot of CPU:

function updateTableCells()
{
var tbl = document.getElementById("tbl");
var tds = tbl.getElementsByTagName("td");
for(var k=0; k<tds.length;k++)
{
tds[k].firstChild.nodeValue = kk;
kk++;
if(kk>10000)kk=5000;
}
}

Jul 23 '05 #10
Raj
>> Every 5 secs fresh data is downloaded from the server. The
downloaded
data is compared against the data currently being displayed in the
table. If any of the cells have changed, the javascript updates the
value of the cell and changes the cell color based on whether the
change is positive or negative from the previous value.

This is not email. Your answer is read by many, so PLEASE quote a relevantpart of the original. Follow usenet netiquette.
I am using http://groups.google.com which has pretty much gmail like
threaded view, so didnt realize the problems other face. Will
copy+paste the relevant parts ... sorry and thanks.
Downloaded to a HTML table, how, why?
Then you loose the original table cell content, I suppose.
I suggest you do such comparing on the server, not on the client

browser.

Ok ... let me try to elaborate on the problem. The application shows
the prices of stocks being traded in a web page. When a user logs in to
the application, they can select the stocks they are interested in.
They are then taken to a page which shows the price [and other details]
of the stocks in the form of a table. Every 5 secs there is a script
which downloads the new price list [in csv format] and updates the
cells which have changed. The background colour of the cell is changed
based on whether the new value of the cell is more/less than the
current value.

We did consider forming the HTML [with new background colours] on the
server side. This increases the CPU load on the server side. The
current model uses client side CPU to do the rendering and it works
fine in case of the rich client and incase of firefox browser. The
problem is only with IE. Once the page is loaded in IE, it takes 100%
CPU for couple of mins and then drops for a sec or so and then it takes
off again.

I donot think it is a problem with changing the style of the cells.
Just updating the cell values takes up a whole lot of CPU:

function updateTableCells()
{
var tbl = document.getElementById("tbl");
var tds = tbl.getElementsByTagName("td");
for(var k=0; k<tds.length;k++)
{
tds[k].firstChild.nodeValue = kk;
kk++;
if(kk>10000)kk=5000;
}
}

Jul 23 '05 #11
VK
> if (navigator.appName.indexOf('Microsoft')! =-1) {

<--snip-->

And you have just introduced a very unreliable method into your script.
Namely, by trying to identify the browser based on the navigator object.
A better solution is to test for the actual object/properties you want
to use. The c.l.j FAQ covers it.


Exceptions are just proof of the rule :-)

In this particular case:
1) There is only one browser using TOM, and it will be only one (unless
Mozilla & Co deside to drop standards and follow Microsoft :-).
2) Methods/properties check gets more and more difficult in IE, because they
are actively covering their non-standard parts with mimic DOM-interfaces,
like one mentioned in my OP.

So in this particular case a simple name check MAY be the most reliable way.


Jul 23 '05 #12
On Tue, 7 Dec 2004 14:48:12 +0100, VK <sc**********@yahoo.com> wrote:

[snip]
1) There is only one browser using TOM, and it will be only one (unless
Mozilla & Co deside to drop standards and follow Microsoft :-).
If you're dealing solely with IE, then use conditional comments. However,
I can't recall having any problems using the W3C DOM to manipulate table
structures in IE.

[snip]
So in this particular case a simple name check MAY be the most reliable
way.


No, it won't. The very reason for not sniffing is that browsers do fake
their identity, but more often than not, they do not actually emulate that
browser functionally. Your test would pick up Opera if it were spoofing
IE, but Opera only has limited support for the proprietary nonsense that
IE includes.

If you'd rather use Microsoft's proprietary object model, then test for
that before methods and properties of the W3C DOM.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #13
VK
> I can't recall having any problems using the W3C DOM to manipulate table
structures in IE.


Mmm... Clone rows within the table or to another table? Get/alter rows'
content? Speedy cells manipulation in a Big x Big table (see the OP)?
So in this particular case a simple name check MAY be the most reliable
way.


No, it won't.


<snip>

Conceived and agreed
:-) :-|
Jul 23 '05 #14
On Tue, 7 Dec 2004 15:58:13 +0100, VK <sc**********@yahoo.com> wrote:
I can't recall having any problems using the W3C DOM to manipulate
table structures in IE.
Mmm... Clone rows within the table or to another table?


Yes. IE has no problem with HTMLTableRowElement.cloneNode nor
HTMLTableSectionElement.appendChild.
Get/alter rows' content?
Yes, but I'll admit that can get awkward. It depends on the content and
what you're doing with it.
Speedy cells manipulation in a Big x Big table (see the OP)?


Personally, I wouldn't attempt to do that at all in a browser. It's not
suited to the job.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #15
"VK" <sc**********@yahoo.com> wrote:
Speedy cells manipulation in a Big x Big table (see the OP)?


http://www.quirksmode.org/dom/innerhtml.html suggests the OP should
give recreating the table in a string and then assiging using innerHTML
a try.

Bye,
Martin
Jul 23 '05 #16

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: josephrthomas | last post by:
hi..i am trying to make a login page and i am using access table.. when the user enters his userid and password i want to check the password from the table.. if any user with the userID that is...
29
by: Thomas | last post by:
Hi I have an XSL stylesheet: <xsl:for-each select="TRACKS/TRACK"> <tr class="TDL"> <td width="90%"><xsl:number value="position()" format="1" /> - <xsl:value-of select="TRACKTITLE"/></td>...
3
by: Joshua Coady | last post by:
Do Trace calls have any impact on performance if Trace is disabled in the config file? Josh
11
by: Pohihihi | last post by:
I was wondering what is the ill effect of using try catch in the code, both nested and simple big one. e.g. try { \\ whole app code goes here } catch (Exception ee) {}
2
by: Stefan Kuhr | last post by:
Hello everyone, I hope this is not an FAQ and that somebody can answer this: As part of our webservice installation we run aspnet_regiis.exe -ir -enable on computers where the web...
0
Savage
by: Savage | last post by:
I'm making for fun a simple program which format a input file.Input file sustain of person name,lastname and date of birth.Output file si supposed to be forammted as following: NAME ...
2
by: mnacw | last post by:
Can anybody help me to resolve this prob. i have installed Visual Studio 2005 Professional edition. I am working in VB.Net. When I tried to connect to database it is connected but when i make some...
1
by: Ben | last post by:
Hi, I registered some custom perf counters that i want to use in my app (all of type NumberOfItems32). I added them under the same category name but different counter names... Same code work...
1
by: Ben | last post by:
hi, i have this line in a web app to create a custom perf category: PerformanceCounterCategory.Create(categoryName, categoryDesc, PerformanceCounterCategoryType.SingleInstance, ccdc); ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.