Richard, you are the man. your setTimeout() method works beautifully.
I can display the partial results so it doesn't look ridiculous.
Thanks,
Jonah
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Richard
Bennett
Sent: Friday, July 13, 2001 5:13 PM
To: [EMAIL PROTECTED]
Subject: Re: [Dynapi-Help] one more question
Much testing is the only way to be sure, but you could try this:
for (var i in this.records) {
for (var j in this.records[i])
txt += '<span>' + this.records[i][j] + '</span>'
txt += '<br>'
}
coupled with a stylesheet to make the span look like table cells:
SPAN{
border:1 inset steelblue;
background-color:#ddffff;
}
you might have to play with the border and padding values.
The border wouldn't show up in NS4 though.
If it's really the looping that's wasting the time, not the rendering, you
could try using a setTimeout, instead of a for-loop. This is because every
time a setTimeout loops, it gives other processes a chance to do their
thing, while a for loop will run it's whole course, before letting other
tasks pick up, this might cause a white screen, or apparent freeze, while
waiting.
I haven't tested this with a large array, but you could try:
var txt='<table>'
var i=0
function makeTable(){
txt += '<tr>'
for (var j in this.records[i])
txt += '<td>' + this.records[i][j] + '</td>'
txt += '</tr>'
if(i<this.records.length){
i++
setTimeout('makeTable()',0)
}
}
txt+='</table>'
makeTable()
I don't know, it might make things worse, but the idea is that for every new
record, other processes, like screen rendering, get a chance to act, this
should make the waiting period less obvious, as other things keep working.
Richard.
----- Original Message -----
From: "Jonah" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: 14 July, 2001 01:28
Subject: RE: [Dynapi-Help] one more question
> Richard, thanks for all the ideas. It turns out, though, (after more
> testing) that the
> problem is neither sort speed nor memory. Even when I have about 1000
> records, sort() itself takes only about two seconds. The ridiculous time
> lag occurs
> when I write them out to a table for display, which takes about 15
seconds.
> Rendering the table
> takes only about 2-3 seconds, but simply creating the text to be rendered
is
> for
> some strange reason very slow. I can't see any way around it. Can you?
> Here is the offending loop:
>
> for (var i in this.records) {
> txt += '<tr>'
> for (var j in this.records[i])
> txt += '<td>' + this.records[i][j] + '</td>'
> txt += '</tr>'
> }
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Richard
> Bennett
> Sent: Friday, July 13, 2001 3:43 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [Dynapi-Help] one more question
>
>
> I think the first thing to do is find out what's eating all the memory,
try
> loading up the array, without writing the contents, measure the memory
use,
> and compare to a light page.
> If it's not so bad, I would suggest leaving the table out, and trying to
use
> as little html tags as possible to render the contents. using <span> tags
> gets more or less the same effect as a table, if you add a stylesheet. I
> found nested tables to be real memory eaters. Also avoid nesting divs and
> spans.
> The <a href> tag can also be useful, as using CSS it can look like a
button,
> while degrading nicely in NS4, it uses a lot less memory than a dhtml
> button.
> If the array by itself doesn't use too much memory, you could copy the
array
> once or twice, and sort the copies as needed, before they are called, once
a
> user selects to sort the table, they don't have to wait for the array to
> sort, as it already did, if you know what I mean.
> Also, the sorting only happens once, so if they click between columns the
> action should be fast.
>
> just a few ideas...
>
> Cheers,
> Richard Bennett
>
> [EMAIL PROTECTED]
> www.richardinfo.com
> (Everything running on, and ported to DynAPI2.53)
> visit the DynAPI homepage (and FAQ) ::
> http://dynapi.sourceforge.net/dynapi/index.php?menu=1
> Browse (and search) the mailinglist here:
> http://www.mail-archive.com/index.php3?hunt=dynapi
>
>
> ----- Original Message -----
> From: "Jonah" <[EMAIL PROTECTED]>
> To: "Dynapi-Help" <[EMAIL PROTECTED]>
> Sent: 13 July, 2001 22:29
> Subject: [Dynapi-Help] one more question
>
>
> > I'm having another, somewhat related problem, which seems due to
> JavaScript
> > memory constraints. I initialize a large number of JavaScript arrays
(the
> > problem seems to start at about 1000) and then loop through them and
> display
> > them in a table, which I write to the page using setHTML() on a
DynLayer.
> > This crashes IE 5.5. Does anyone know what the problem is and if there
is
> a
> > way to fix it?
> >
> >
> >
> > _______________________________________________
> > Dynapi-Help mailing list
> > [EMAIL PROTECTED]
> > http://lists.sourceforge.net/lists/listinfo/dynapi-help
> >
>
>
> _______________________________________________
> Dynapi-Help mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dynapi-help
>
>
> _______________________________________________
> Dynapi-Help mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dynapi-help
>
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help
_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help