You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by MrG <ma...@realisingvisions.com> on 2012/11/22 12:49:55 UTC

Performance-Issue, group elements

hi, i try to group a lot of elements (>1000).

this is my code at the moment:

-----------------------------------------------------------
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: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Performance-Issue, group elements

Posted by MrG <ma...@realisingvisions.com>.
Hi,

nodes is a "List<Element>".
the timing of appendChild-Operation is in average 26.434 ms.

If i remove group.appendchild(), it takes <1s to loop. nodes are only
rectangles. 

I tried to suspend Updatemanager, but it doesn't take effect.



--
View this message in context: http://batik.2283329.n4.nabble.com/Performance-Issue-group-elements-tp4655381p4655406.html
Sent from the Batik - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: Performance-Issue, group elements

Posted by Thomas DeWeese <th...@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 <ma...@realisingvisions.com> 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: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
>
>