Re: Increase performance

"Ryan Levering" <[email protected]> Mon, 18 Jun 2007 01:04:45 -0400
Newsgroups gmane.comp.mozilla.jrex
Message-ID <[email protected]>
I got my best results by serializing the DOM in a JS script, executing it 
once from LiveConnect, and reconstructing the DOM on the Java side.  I know 
that may sound crazy, but it's actually really fast.  Definitely minimizes 
JNI calls.

Ryan Levering

"Billy" <florian-lindner-S0/[email protected]> wrote in message 
news:loom.20070509T011955-535-eS7Uydv5nfiQYT8SWwsb6uG/[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