[ka-Map-users] Re: kaXmlOverlay.js speed improvement

Justin George justin.george at gmail.com
Sat Jul 8 14:47:53 EDT 2006


I test in internet explorer and Firefox 1.5.0.3 (using Venkman's
profiler feature)

The reason that the inefficiency is so large is that parse() is called
very often with lots of overlays, and when rerendering overlays. So
any tiny improvement there will affect the whole overlay system quite
a lot.

In particular, dotted references (this.div.innerHTML =
ihtml_element[i].firstChild.nodeValue;) are slow, as are object
creation (used in later loops, eg some_variable = new someObject(); )

There's a whole article about how to speed up javascript (in english)
http://dhtmlkitchen.com/learn/js/perf/

Of course, eliminating loops always helps things, in general.

Hope that helps, and again, thanks a ton for your work, it's really
saved me a ton of time and effort.

J

On 7/8/06, Pg <pg.navone at gmail.com> wrote:
> First of all I apologize for late response.
>
> I didn't do any test by myself, but I'm surprised of a so big
> inefficiency due to the use of single shot loop versus a simple test.
>
> At the moment I think it's not a good idea to apply your solution as
> is in the CVS, because the new version will change the behaviour and
> will not be backward compatible. I would like to understand where is
> the time consuming operation (may be the test on
> "ihtml_element.length" instead of testing the array element?) and
> write a more efficient loop.
>
> Did you measure the inefficiency in a specific browser or in many
> browsers/versions?
>
>
> 2006/6/20, Justin George <justin.george at gmail.com>:
> > Pg, thanks again for your work on the client-side overlays. I have a
> > small patch that might help with speed for rendering lots of ihtml
> > elements.
> >
> > Since they are replacing the value of the inner HTML right now,
> > replacing the loop with an 'if' statement has sped things up for me
> > (rendering approximately 50 points per call) by about ten times.
> >
> > This might also be considered for other types of points, but I'm not
> > sure how many people are using within a single point, so I wouldn't
> > want to unroll the loops for them without being sure that people were
> > using small numbers.
> >
> > In kaXmlOverlay.js, object kaXmlPoint, function parse:
> > replace the
> > for(i=0; i<ihtml_element.length; i++) {
> >
> > with
> >
> > if(ihtml_element[0]) {
> >
> >
> > Or, in unified diff from subversion:
> >
> > @@ -1390,8 +1390,9 @@
> >
> >         // look for ihtml element
> >         var ihtml_element = point_element.getElementsByTagName("ihtml");
> > -       for (i=0; i<ihtml_element.length; i++) {
> > -               this.div.innerHTML = ihtml_element[i].firstChild.nodeValue;
> > +
> > +       if(ihtml_element[0]) {
> > +               this.div.innerHTML = ihtml_element[0].firstChild.nodeValue;
> >
> > Thanks again,
> > J
> >
>


More information about the ka-Map-users mailing list