Re: [Rd] Creating XML document extremely slow

From: Titus von der Malsburg <>
Date: Fri, 10 Feb 2012 19:12:45 +0100

On Fri, Feb 10, 2012 at 6:43 PM, Milan Bouchet-Valat <> wrote:
> Doesn't sound so bad to me. I don't think you'll find a use case where
> 3s will really be a problem.

Actually I have exactly such a case because I have to produce many such documents and a difference of two orders of magnitude in processing matters greatly.

> From what Rprof() says, xmlNode() doesn't seem to do anything obviously
> wrong. It's just that you're calling it 500 times, so there's some
> overhead. You'd need a vectorized version that would handle all the data
> in one go

My code that patches together strings is also not vectorized and does something in 500 iteration. Still it is 300 times faster than the solution that uses the XML package. Also, I could only bring down the processing time of the code that uses XML package to 3 seconds because (i) the amount of data that was very small and (ii) because the XML document had a very repetitive structure. Documents with a more varied structure don't allow the kind of optimization that you proposed and if they have a non-trivial size the processing time can easily become prohibitive.

Anyway, my problem is solved because I'm switched to my own homebrewed xml generation and it works fine.

  Titus mailing list Received on Fri 10 Feb 2012 - 18:16:11 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 10 Feb 2012 - 23:10:16 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive