Increase performance

Billy <florian-lindner-S0/[email protected]> Tue, 8 May 2007 23:40:37 +0000 (UTC)
Newsgroups gmane.comp.mozilla.jrex
Message-ID <[email protected]>
Hi,
I have some performance problems.

Here is one example:

1) Extract a DOM document
2) Create a NodeList of all Elements with tag "A" (links)
3) do a for loop on all this nodes of the nodelist
4) Simulate a click event

That all takes over 1 second.

Step 1) and 2) take 0.1 seconds together and step 4) 0.1 seconds alone.
Step 3) takes a lot of time. My for loop looks like that:

for (int i=0;i<nodelist.getLength();i++) {
    if (nodelist.item(i).getAttribute("aAttribute").equals("foo"))
      if (nodelist.item(i).getTextContent().toLowerCase().equals("sth")
          <do a click ~ step 4>
}

These 1.5 seconds are measured for a document with 16 links in the
nodelist. Why does it take such a lot time? Is this caused by my system
(Windows XP, 512MB RAM, 1,4 GHz Intel Centrino)
or does JRex need a lot of time for iterating over a
nodelist and get some tags? If so is there any way to improve the
performance here?
Thx and best regards.
Billy