Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      3

      Description

      With the drop of September 7, 2005, I did some performance comparisons with
      regards to its performance relative to the default SAX parser of Sun's JDK 1.5.

      I understand that performance comparisons between two different XML parser APIs
      is not trivial. I did try to design my test program so that the program
      retrieves the same data (local names, prefixes, character content...), so that
      the comparison is as fair.

      I compared parsing different input file sizes. The actual XML input files are
      those generated by XMark (http://monetdb.cwi.nl/xml/). Each file was parsed a
      number of times (500) using SAX and using sjsxp.

      Timing results are:

      xmark_0.00001.xml - sjsxp: 661 ms
      xmark_0.00001.xml - SAX: 571 ms
      xmark_0.0001.xml - sjsxp: 771 ms
      xmark_0.0001.xml - SAX: 691 ms
      xmark_0.001.xml - sjsxp: 2534 ms
      xmark_0.001.xml - SAX: 1912 ms
      xmark_0.01.xml - sjsxp: 24970 ms
      xmark_0.01.xml - SAX: 18491 ms

      My conclusion is that there's a general overhead in sjsxp that grows as the XML
      input file grows. It would have thought that the parser would perform as equal
      as the SAX parser as both are Xerces based. Is this performance issue known or
      at least explainable?

      Below is the source code of the testing program:

      import java.io.File;
      import java.io.FileInputStream;
      import javax.xml.parsers.SAXParser;
      import javax.xml.parsers.SAXParserFactory;
      import javax.xml.stream.XMLInputFactory;
      import javax.xml.stream.XMLStreamReader;
      import org.xml.sax.helpers.DefaultHandler;

      public class XmlParserPerformance {

      private final int nrOfRuns = 500;

      private final String[] xmlFileNames = new String[]

      { "xml/xmark_0.00001.xml" , "xml/xmark_0.0001.xml" , "xml/xmark_0.001.xml" , "xml/xmark_0.01.xml" , "xml/xmark_0.1.xml" , "xml/xmark_1.xml" }

      ;

      private File xmlFile;

      private void go() throws Exception {
      // Init
      initSTAX();
      initSAX();
      // Warm up run
      xmlFile = new File(xmlFileNames[0]);
      testSTAX();
      testSAX();
      // Actual timings
      System.out.println("===== Start timings =====");
      for (int fileIx = 0; fileIx < xmlFileNames.length; fileIx++)

      { xmlFile = new File(xmlFileNames[fileIx]); // STAX testSTAX(); // SAX testSAX(); }

      }

      // -------------------- STAX --------------------

      private XMLInputFactory xmlInputFactory;

      private void initSTAX() throws Exception

      { xmlInputFactory = XMLInputFactory.newInstance(); }

      private void testSTAX() throws Exception {
      long begin = System.currentTimeMillis(), end = 0;
      for (int i = 0; i < nrOfRuns; i++) {
      XMLStreamReader xsr = xmlInputFactory.createXMLStreamReader(new
      FileInputStream(xmlFile));
      while (xsr.hasNext()) {
      int event = xsr.next();
      xsr.getEventType();
      switch (event)

      { case XMLStreamReader.START_ELEMENT: xsr.getLocalName(); xsr.getPrefix(); xsr.getNamespaceURI(); xsr.getAttributeCount(); xsr.getNamespaceCount(); break; case XMLStreamReader.END_ELEMENT: xsr.getLocalName(); xsr.getPrefix(); xsr.getNamespaceURI(); break; case XMLStreamReader.CHARACTERS: case XMLStreamReader.SPACE: xsr.getText(); break; default: break; }

      }
      }
      end = System.currentTimeMillis();
      System.out.println(xmlFile.getName() + " - sjsxp: " + (end - begin) + " ms");
      }

      // -------------------- SAX --------------------

      private SAXParserFactory saxParserFactory;

      private SAXParser saxParser;

      private void initSAX() throws Exception

      { saxParserFactory = SAXParserFactory.newInstance(); saxParser = saxParserFactory.newSAXParser(); }

      private void testSAX() throws Exception {
      long begin = System.currentTimeMillis(), end = 0;
      for (int i = 0; i < nrOfRuns; i++)

      { saxParser.parse(xmlFile, new DefaultHandler()); }

      end = System.currentTimeMillis();
      System.out.println(xmlFile.getName() + " - SAX: " + (end - begin) + " ms");
      }

      public static void main(String[] args) {
      try

      { new XmlParserPerformance().go(); }

      catch (Exception e)

      { e.printStackTrace(); }

      }

      }

        Activity

        Hide
        Santiago Pericas-Geertsen added a comment -

        We haven't seen this behavior in other benchmarks, but I'll investigate.

        Show
        Santiago Pericas-Geertsen added a comment - We haven't seen this behavior in other benchmarks, but I'll investigate.
        Hide
        Santiago Pericas-Geertsen added a comment -

        In all our internal testing, SJSXP is as fast or faster than Xerces SAX. Please try the latest and re-open if
        necessary.

        Show
        Santiago Pericas-Geertsen added a comment - In all our internal testing, SJSXP is as fast or faster than Xerces SAX. Please try the latest and re-open if necessary.

          People

          • Assignee:
            Santiago Pericas-Geertsen
            Reporter:
            wcordewiner
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: