I've run simple comparison tests for fastjaxb from resteasy and xb based on the
"person" test from fastjaxb.
The results don't look that promising for fastjaxb, especially taking into account its
binding features at this point are still primitive.
repetitions - number of unmarshallings of Person
total - total time in ms for all the repetitions
avg - average time ms for single repetition
repetitions 1
fast jaxb total=139, avg=139.0
xb total=47, avg=47.0
repetitions 10
fast jaxb total=151, avg=15.1
xb total=106, avg=10.6
repetitions 100
fast jaxb total=249, avg=2.49
xb total=286, avg=2.86
repetitions 1000
fast jaxb total=1057, avg=1.057
xb total=1402, avg=1.402
Here is the test
public class FastJaxbUnitTestCase extends TestCase
| {
| public FastJaxbUnitTestCase()
| {
| }
|
| private long repetitions = 1000;
| public void testFastJaxb() throws Exception
| {
| ParsingCommand c = new FastJaxbParsing(repetitions);
| c.run();
| System.out.println("fast jaxb total=" + c.getTotal() + ",
avg=" + c.getAverage());
| }
|
| public void testXB() throws Exception
| {
| ParsingCommand c = new XBParsing(repetitions);
| c.run();
| System.out.println("xb total=" + c.getTotal() + ", avg=" +
c.getAverage());
| }
|
| private static class XBParsing extends ParsingCommand
| {
| private static final UnmarshallerFactory factory =
UnmarshallerFactory.newInstance();
| private SchemaBinding schema;
|
| protected XBParsing(long repetitions)
| {
| super(repetitions);
| }
|
| @Override
| protected void setup() throws Exception
| {
| super.setup();
| schema = JBossXBBuilder.build(Person.class);
| }
|
| @Override
| protected void parse() throws Exception
| {
| Unmarshaller unmarshaller = factory.newUnmarshaller();
| unmarshaller.unmarshal(xmlUri, schema);
| }
| }
|
| private static class FastJaxbParsing extends ParsingCommand
| {
| private static SAXParserFactory factory = SAXParserFactory.newInstance();
| static
| {
| factory.setNamespaceAware(true);
| }
|
| private Sax sax;
|
| protected FastJaxbParsing(long repetitions)
| {
| super(repetitions);
| }
|
| @Override
| protected void parse() throws Exception
| {
| SAXParser parser = factory.newSAXParser();
| parser.parse(xmlUri, sax);
| }
|
| @Override
| protected void setup() throws Exception
| {
| super.setup();
| HashMap<String, Handler> map = new HashMap<String, Handler>();
| map.put("urn:person", new Person_Parser());
| sax = new Sax(map);
| }
| }
|
| private static abstract class ParsingCommand
| {
| protected long repetitions;
| protected long total;
| protected String xmlUri;
|
| protected ParsingCommand(long repetitions)
| {
| this.repetitions = repetitions;
| }
|
| public long getTotal()
| {
| return total;
| }
|
| public double getAverage()
| {
| return ((double)total)/repetitions;
| }
|
| public long getRepetitions()
| {
| return repetitions;
| }
|
| protected void setup() throws Exception
| {
| xmlUri =
Thread.currentThread().getContextClassLoader().getResource("person.xml").toExternalForm();
| }
|
| protected abstract void parse() throws Exception;
|
| public void run() throws Exception
| {
| setup();
|
| for(int i = 0; i < repetitions; ++i)
| {
| long start = System.currentTimeMillis();
| parse();
| total += System.currentTimeMillis() - start;
| }
| }
| }
| }
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4257878#...
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&a...