Hi Naveed,
noni_4444 <[EMAIL PROTECTED]> wrote on 09/28/2007 01:43:07 AM:
> Even after i have tried to take the detach->update->replace cycle out of
my
> for loop (running around 200 to 400 times) there is no performance
> improvement. Now instead of setAttribute taking long time, it is the
> replaceChild method which is eating upto 45% of the CPU time.
The time in either case is the time for Batik to re-layout the text.
Layout of text is known to be slow, unfortunately the major bottlenecks
are in JDK classes (most notably AttributedString).
I am fairly certain that the text code is as fast as it can be
given the current design. Making it faster will require significant
rearchitecting of the code. To use a faster (probably less flexible)
version of AttributeString, and to add 'simple text' code paths that
avoid the speed hit associated with things like bidi text,
vertical/horizontal
layout, text stretch/shrink, mid text font changes, mid text fill changes,
explicit tspan placements, etc...
> Isn't replaceChild for nodes with large subtrees an expensive operation?
If
> yes, how could one try to improve performance by replacing the
replaceChild
> method. Isn't there any efficient way to perform this
> detach->update->replace cylce for nodes with large subtrees.
Trust me on this. The DOM is _not_ the problem, the problem is the
graphics work that modifying the DOM causes.
> noni_4444 wrote:
> >
> > All my modifications are in a single runnable. The text elements i
want to
> > modify are not
> > children of a single node but are spread out over the document. So its
a
> > bit more complex,
> > anywayz i will find some way to handle it.
> >
> > But there is still the questions that how would doing this reduce the
time
> > spend in setAttribute
> > etc methods. To me it seems that the problem lies in dom code, where
it
> > creates new nodes
> > and remove nodes for even simple things like setNodeValue. Just take a
> > look at the code of
> > setNodeValue and it appears anything but efficient.
> >
> > To me the final solution seems to be to find a way to bypass the dom
> > somehow.
> > Any comments. Problem lies with dom code or the way we update
document?
> > What different options
> > are available?
> >
> > Thanks
> > Naveed
> >
> >
> > Daniel Meyer-2 wrote:
> >>
> >> Hello Naveed
> >>
> >> I don't know how your Document is structured, but if all Text
Elements
> >> were childnodes of the same node x, you could just unlink this node x
> >> update its childnodes and then link back the node x.
> >> This is the point in unlinking anyway, making multiple modifications
in
> >> one go.
> >>
> >> Another question, do you perform all your modifications in one single
> >> Runnable?
> >>
> >> Daniel
> >>
> >> noni_4444 wrote:
> >>>> Node parent = textElement.getParentNode();
> >>>> Node stub = parent.getOwnerDocument().createElement("g");
> >>>> // unlink element
> >>>> parent.replaceChild(stub, textElement);
> >>>> // run your updates
> >>>> // re link element
> >>>> stub.getParentNode().replaceChild(textElement, stub);
> >>>
> >>> Trying above code did reduce the CPU usage by 3 to 4% but now
replace
> >>> child
> >>> becomes a problem by taking up 35% of cpu time. I get an array of
> >>> textElements and have to iterate over the array in a loop to call
> >>> (unlink->update->replace) for each text element. So taking the
> >>> replaceChild
> >>> function out of the loop seems impossible.
> >>>
> >>> Is it possible to take this replaceChild method call out of the
loop,
> >>> when i
> >>> just receive an array of text elements?
> >>>
> >>> Thanks,
> >>> Naveed
> >>>
> >>> noni_4444 wrote:
> >>>> I have a routine where i update several DOM elements inside an
update
> >>>> manager
> >>>> thread. The problem faced
> >>>> is that setAttribute and setNodeValue methods take a lot of CPU
time.
> >>>>
> >>>> An earlier post says:
> >>>>
> >>>> "Disconnect the tree from the document before making the changes.
This
> >>>> avoids the overhead of keeping the GVT tree in synch with every
change"
> >>>>
> >>>> In my case i am updating the multiple attributes of different
Elements
> >>>> repeatedly. How can i detach the attributes of an element before
making
> >>>> the
> >>>> changes.
> >>>> If i do it, it would mean that i do something like
> >>>>
> >>>> for (1 -> n)
> >>>> {
> >>>> Get current element from array
> >>>> Detach attributes of element //which dom api method to
> >>>> call????
> >>>> Update multiple attributes of this element
> >>>> Attach attributes of element //which dom api method to
> >>>> call????
> >>>> }
> >>>>
> >>>> Any pointers, links, references would be helpful.
> >>>>
> >>>> Thanks
> >>>> Naveed
> >>>
> >>>
> >>>
---------------------------------------------------------------------
> >>> To unsubscribe, e-mail:
[EMAIL PROTECTED]
> >>> For additional commands, e-mail:
[EMAIL PROTECTED]
> >>>
> >>>
> >>>
> >>>
> >>
> >> --
> >> Mit freundlichen Grüßen,
> >> Daniel Meyer
> >>
> >> Steinstraße 37, 10119 Berlin
> >> Deutschland
> >> Telefon: +49 3031004846
> >>
> >> conTour Software und Design GBR
> >> 9, rue Kemel, L-9831 Consthum
> >> Luxemburg
> >> Inhaber: Christiane Teuschler, Meyer Daniel
> >> Geschäftsführer: Meyer Daniel
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail:
[EMAIL PROTECTED]
> >> For additional commands, e-mail:
[EMAIL PROTECTED]
> >>
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Help-%21-how-to-
> make-updates-to-dom-more-efficient---tf4528109.html#a12934972
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]