Re: Performance-Issue, group elements

Thomas DeWeese <[email protected]>
Newsgroups gmane.text.xml.batik.user
Message-ID <CACTtnu2p9safkzXGnDZg61H645qu3SWdjdU1y0b1B6Tqm5KMEQ@mail.gmail.com>
Hi MrG,

   Do you know what sort of container nodes is?  If it's something like a
linked list it may be that simply getting the elements out of it is taking
your 8sec.
With a linked list getting element 900 the way you are will take 900
pointer traversals so getting 1000 elements out of the container with 'get'
would take
~1 million operations (and it goes up quickly from there).  In general our
appendChild is a quick operation so I wouldn't expect that to be causing
your problems.

   Other things you might consider, does the 8sec include rendering the 1K
elements?  That might be believable depending on the complexity of the
elements.
You might also try timing the loop removing the appendChild call (i.e.
seeing how long calling nodes.get(i) takes when you iterate across the
whole container).

On Thu, Nov 22, 2012 at 3:49 AM, MrG <[email protected]> wrote:

> Element group =
> editor.doc.createElementNS(editor.svgNS, SVGConstants.SVG_G_TAG);
> group.setAttributeNS(null, "id", groupID);
>
> for(int i=0; i<nodes.size(); i++) {
>         group.appendChild(nodes.get(i));
> }
>
> editor.doc.getRootElement().appendChild(group);
> -----------------------------------------------------------
>
> this takes a lot of time > 8s
>
> is there a way to optimize grouping elements?
>
> thanks!
>
>
>
>
> --
> View this message in context:
> http://batik.2283329.n4.nabble.com/Performance-Issue-group-elements-tp4655381.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.