A large stylesheet probably will use some memory, so you don't want to just
keep them around if you're not going to re-use them. On the other hand,
they will be compiled on-the-fly if you just pass in an istream, so you
will end up using the same amount of memory. Your application will want to
find a balance between compilation time and memory usage (just like any
other cache situation). If you're using a small set of stylesheets
frequently, your application will almost always run faster if you use pre-
compiled stylesheets.
I don't know how the performance of the MS implementation of ostreams
compares with other vendors' implementations, but ostream and ostrstream
are always going to be slower than using a callback. It's partly due to
behavior required by the standard which results in synchronization and
partly due to the inherent inefficiency of dynamic memory allocations. One
way to remove the memory allocation is to use your own buffer with
ostrstream:
const size_t bufferSize = 2097152;
char buffer[bufferSize];
ostrstream stream(buffer, bufferSize);
This constrains the output to a fixed maximum size, but removes the
constant reallocation of the ostrstream instance's buffer.
Dave
Holger Floerke
<floerke@doctron To: [EMAIL PROTECTED]
ic.de> cc: (bcc: David N
Bertoni/Cambridge/IBM)
Subject: Re: Xalan-C: Two Ways to
Transform into ByteStream
07/23/2002 08:43
AM
Please respond
to xalan-dev
At 08:34 23.07.2002 -0700, you wrote:
>Hi HolgeR,
>
>Can't you just call XalanTransformer::compileStylesheet() to the compile
>the stylesheet when necessary?
I will do so in the future. But I think compiled stylesheets using large
amount of memory.
>Another way to do this would be to derive a class from Xalan's Writer
>class, which can be used to construct an XSLTResultTarget, although I'd
not
>recommend doing it unless you can't get the callback to work.
Got it. I compile the stylesheet before processing and destroy it after
processing. With my own callback (preallocating 32kB of memory) the
rendering is 2-3 times faster than using ostrstream (result is about 2MB).
This fact is surprising to me. Is it M$ (using MSVCP60SP5) with a *peep*
implementation of ostrstream?
Thank you for supporting,
HolgeR
--
holger floerke d o c t r o n i c
email [EMAIL PROTECTED] information publishing + retrieval
phone +49 2222 9292 90 http://www.doctronic.de
Re: Xalan-C: Two Ways to Transform into ByteStream
David N Bertoni/Cambridge/IBM Tue, 23 Jul 2002 08:49:38 -0700
- Xalan-C: Two Ways to Transform into ByteStre... Holger Floerke
- Re: Xalan-C: Two Ways to Transform into... David N Bertoni/Cambridge/IBM
- Re: Xalan-C: Two Ways to Transform ... Holger Floerke
- Re: Xalan-C: Two Ways to Transform into... David N Bertoni/Cambridge/IBM
- Re: Xalan-C: Two Ways to Transform ... Holger Floerke
- David N Bertoni/Cambridge/IBM
