[jdom-interest] JDOMTransformer

Laurent Bihanic laurent.bihanic at atosorigin.com
Mon May 5 09:11:09 PDT 2003


Jason Hunter wrote:
>>The question here is what the performance cost of allocating a new
>>Transformer object is. Certainly it's less than creating by parsing
>>the stylesheet from scratch, but perhaps it's still significant. In
>>general, nothing in JDOM promises thread safety. Is there a benchmark
>>in the house?
> 
> Dunno.  I'm guessing it's as fast as an object allocation, which should
> be very fast relative to the overhead in a transformation.  But gut
> guessing isn't good at predicting true performance.

A quick look at Saxon's code show that allocating a Transformer amounts to 
create about 10 objects.
 From a performance standpoint, I always store Templates and allocate a new 
Transformer for each transformation, not even caring for reusing Transformers 
when in the same thread.

But the real value of keeping a Templates object rather than a Transformer is 
that the JDOMTransformer class can be used as is in web applications rather 
than having to resort to a ThreadLocal variable to ensure thread-safe access.
That really helps programmers to make their code simpler.

Laurent




More information about the jdom-interest mailing list