Chillax
Chillax

Reputation: 4728

Performance considerations while using Xstream for XML conversions

I am doing profiling on my Java application which consists mainly of web-services. The result shows that most of the time is spent in converting the XML's.

I am currently using XStream ( Version 1.3.1 ) for the conversion. Will I get a better performance if I upgrade the version? Or is there anything else which I could use which can give me a better performance ( like JAXB) ?

Upvotes: 1

Views: 5621

Answers (2)

Jasper Blues
Jasper Blues

Reputation: 28756

There is a marshaller that is designed especially for performance, while at the same time being true to the term mashaller. . . (Whereas Xstream is a serializer, because it outputs by convention, and you can't tune the XML that gets produced by using eg a mapping file. . Not that I have anything against XStream). .

The performant marshaller was started in Wellington, New Zealand a number of years ago. . . And is called JIBX. Here's the website: http://jibx.sourceforge.net/

It is one of the marshallers supported explicitly by the Spring Framework.

Upvotes: 0

bdoughan
bdoughan

Reputation: 149017

Ultimately you will need to create a bench mark appropriate to your use case to determine which XML-binding library is best for your use cases. There are too many factors to declare one ultimate winner (i.e One may be super fast, until it hits an inheritance hierarchy, and one super fast handling inheritance but slows down on collections).

Within a framework generally dealing with StAX or streams is faster than dealing with DOM so if you can position your code this way you are better off. Also binding frameworks generally leverage lower level parsers so using JAXB with Woodstox may improve performance for you.

JAXB & Performance

The JAXBContext represents the processed metadata and this class is thread safe. You will see a peformance benefit if you create it once and reuse it.

Upvotes: 2

Related Questions