axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eran Chinthaka <chinth...@opensource.lk>
Subject Re: [Axis2] AXIOM vs. JDOM trivial perf test
Date Fri, 31 Mar 2006 02:28:25 GMT
Hi all,

We didn't do a perf improvement in OM for some time, so it may be true
that om is not as performing as one expects. But Dims results indicate
that even the results are jdk impl dependent.

(I know for sure that the XMLStreamWriter is slow compared to others,
but I think none of you have seriliazed your xmls during these tests)

-- Chinthaka

Davanum Srinivas wrote:
> Glen,
> 
> I used the IBM-IBM-Axis.xml from the Addressing interop as my
> bigfile.xml. Running the test 5 times each under 5 jdk's on my
> thinkpad, here are the results. Please see my console output as well
> attached as text file. It has the specific "java -version" output for
> each jdk.
> 
> JROCKIT-1.5  (OM)         39  26  26  25  24
> JROCKIT-1.5  (JDOM)       47  58  45  62  53
> 
> SUN-JDK-1.5  (OM)         52  51  52  52  53
> SUN-JDK-1.5  (JDOM)       49  52  49  49  51
> 
> SUN-JDK-1.6  (OM)         35  37  34  35  31
> SUN-JDK-1.6 (JDOM)        29  29  27  28  28
> 
> IBM-JDK-1.5 (OM)          32  27  26  24  29
> IBM-JDK-1.5 (JDOM)        32  23  22  22  21
> 
> SUN-JDK-1.4 (OM)          50  49  51  50  49
> SUN-JDK-1.4 (JDOM)        45  47  45  45  47
> 
> [1] http://www.w3.org/2002/ws/addr/testsuite/report/IBM-IBM-Axis.xml
> 
> Thanks,
> dims
> 
> On 3/30/06, Glen Daniels <glen@thoughtcraft.com> wrote:
>> Hi folks:
>>
>> The following is a quick test which takes an XML input file, parses it,
>> and walks the tree collecting all text content.  It does this using both
>> JDOM (note that you'll need the StAXBuilder and StAXTextModifier which
>> you can find at http://svn.woodstox.codehaus.org/utils/jdom/) and AXIOM,
>> 100 times each, and then averages the timings.  The code is as close to
>> identical as I could get for the two packages.
>>
>> For the file I'm working with (about 150K) I'm seeing AXIOM get an
>> average time around 180ms, whereas JDOM comes in at around 77ms.  The
>> strings match up.  This could be better, because frankly JDOM is way
>> easier to use. :)
>>
>> I think it might be time to integrate some performance testing into our
>> builds, and to do some optimization on AXIOM.  I haven't yet looked at
>> comparing memory footprints, but may try to do that sometime soon.
>>
>> --Glen
>>
>> --------
>>
>> import org.apache.axiom.om.OMXMLParserWrapper;
>> import org.apache.axiom.om.OMAbstractFactory;
>> import org.apache.axiom.om.OMElement;
>> import org.apache.axiom.om.OMNode;
>> import org.apache.axiom.om.impl.llom.factory.OMXMLBuilderFactory;
>> import org.jdom.input.StAXBuilder;
>> import org.jdom.Document;
>> import org.jdom.Element;
>> import org.jdom.Content;
>>
>> import javax.xml.stream.XMLStreamReader;
>> import javax.xml.stream.XMLInputFactory;
>> import java.io.FileInputStream;
>> import java.util.Iterator;
>> import java.util.List;
>> import java.util.Date;
>>
>> public class Test {
>>      static class Timer {
>>          long startTime;
>>          long stopTime;
>>
>>          public void start() {
>>              startTime = new Date().getTime();
>>          }
>>
>>          public long stop() {
>>              stopTime = new Date().getTime();
>>              return (stopTime - startTime);
>>          }
>>      }
>>
>>      // A place to save the string length for comparison purposes
>>      static int strLen = 0;
>>
>>      public static void main(String[] args) throws Exception {
>>          // Replace with any big file
>>          String FILENAME = "Scratch/bigfile.xml";
>>
>>          int NUM_RUNS = 100;
>>          long accum = 0;
>>
>>          for (int i = 0; i < NUM_RUNS; i++) {
>>              FileInputStream fis = new FileInputStream(FILENAME);
>>              XMLStreamReader parser =
>> XMLInputFactory.newInstance().createXMLStreamReader(fis);
>>              accum += runAXIOMTest(parser);
>>              parser.close();
>>              fis.close();
>>          }
>>          System.out.println("OM avg was " + (accum / NUM_RUNS) +
>>                  " (" + strLen + ")");
>>
>>          strLen = 0;
>>          accum = 0;
>>
>>          for (int i = 0; i < NUM_RUNS; i++) {
>>              FileInputStream fis = new FileInputStream(FILENAME);
>>              XMLStreamReader parser =
>> XMLInputFactory.newInstance().createXMLStreamReader(fis);
>>              accum += runJDOMTest(parser);
>>              parser.close();
>>              fis.close();
>>          }
>>          System.out.println("JDOM avg was " + (accum / NUM_RUNS) +
>>                  " (" + strLen + ")");
>>      }
>>
>>      public static long runAXIOMTest(XMLStreamReader parser) throws
>> Exception {
>>          Timer t = new Timer();
>>          t.start();
>>          OMXMLParserWrapper builder =
>> OMXMLBuilderFactory.createStAXOMBuilder(OMAbstractFactory.getOMFactory(),
>> parser);
>>          OMElement root = builder.getDocumentElement();
>>          StringBuffer buf = new StringBuffer();
>>          genAXIOMString(root, buf);
>>          long elapsed = t.stop();
>>          if (strLen == 0) {
>> //            System.out.println("[" + buf.toString() + "]");
>>              strLen = buf.length();
>>          }
>>          return elapsed;
>>      }
>>
>>      public static long runJDOMTest(XMLStreamReader parser) throws
>> Exception {
>>          Timer t = new Timer();
>>          t.start();
>>          StAXBuilder builder = new StAXBuilder();
>>          Document doc = builder.build(parser);
>>          StringBuffer buf = new StringBuffer();
>>          Element root = doc.getRootElement();
>>          genJDOMString(root, buf);
>>          long elapsed = t.stop();
>>          if (strLen == 0) {
>> //            System.out.println("[" + buf.toString() + "]");
>>              strLen = buf.length();
>>          }
>>          return elapsed;
>>      }
>>
>>      // These two methods do the exact same thing, one for AXIOM and one
>>      // for JDOM.  Walk the tree and collect all the text.
>>
>>      public static void genAXIOMString(OMElement el, StringBuffer buf) {
>>          buf.append(el.getText());
>>          Iterator i = el.getChildren();
>>          while (i.hasNext()) {
>>              OMNode node = (OMNode)i.next();
>>              if (node instanceof OMElement) {
>>                  OMElement element = (OMElement) node;
>>                  genAXIOMString(element, buf);
>>              }
>>          }
>>      }
>>
>>      public static void genJDOMString(Element el, StringBuffer buf) {
>>          buf.append(el.getText());
>>          List children = el.getChildren();
>>          for (Iterator i = children.iterator(); i.hasNext();) {
>>              Content content = (Content)i.next();
>>              if (content instanceof Element) {
>>                  Element element = (Element)content;
>>                  genJDOMString(element, buf);
>>              }
>>          }
>>      }
>> }
>>
> 
> 
> --
> Davanum Srinivas : http://wso2.com/blogs/
> 
> 
> ------------------------------------------------------------------------
> 
> C:\perf>java -version
> java version "1.5.0_04"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
> BEA JRockit(R) (build R26.0.0-189-53463-1.5.0_04-20051122-2041-win-ia32, )
> 
> C:\perf>java Test
> OM avg was 39 (119723)
> JDOM avg was 47 (119723)
> 
> C:\perf>java Test
> OM avg was 26 (119723)
> JDOM avg was 58 (119723)
> 
> C:\perf>java Test
> OM avg was 26 (119723)
> JDOM avg was 45 (119723)
> 
> C:\perf>java Test
> OM avg was 25 (119723)
> JDOM avg was 62 (119723)
> 
> C:\perf>java Test
> OM avg was 24 (119723)
> JDOM avg was 53 (119723)
> 
> [SNIP]
> 
> C:\perf>java -version
> java version "1.5.0_06"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
> Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode)
> 
> C:\perf>java Test
> OM avg was 52 (119723)
> JDOM avg was 49 (119723)
> 
> C:\perf>java Test
> OM avg was 51 (119723)
> JDOM avg was 52 (119723)
> 
> C:\perf>java Test
> OM avg was 52 (119723)
> JDOM avg was 49 (119723)
> 
> C:\perf>java Test
> OM avg was 52 (119723)
> JDOM avg was 49 (119723)
> 
> C:\perf>java Test
> OM avg was 53 (119723)
> JDOM avg was 51 (119723)
> 
> [SNIP]
> 
> C:\perf>java -version
> java version "1.6.0-rc"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-rc-b71)
> Java HotSpot(TM) Client VM (build 1.6.0-rc-b71, mixed mode)
> 
> C:\perf>java Test
> OM avg was 35 (119723)
> JDOM avg was 29 (119723)
> 
> C:\perf>java Test
> OM avg was 37 (119723)
> JDOM avg was 29 (119723)
> 
> C:\perf>java Test
> OM avg was 34 (119723)
> JDOM avg was 27 (119723)
> 
> C:\perf>java Test
> OM avg was 35 (119723)
> JDOM avg was 28 (119723)
> 
> C:\perf>java Test
> OM avg was 31 (119723)
> JDOM avg was 28 (119723)
> 
> [SNIP]
> 
> C:\perf>java -version
> java version "1.5.0"
> Java(TM) 2 Runtime Environment, Standard Edition (build pwi32dev-20051104)
> IBM J9 VM (build 2.3, J2RE 1.5.0 IBM J9 2.3 Windows XP x86-32 j9vmwi3223-20051103 (JIT
enabled)
> J9VM - 20051027_03723_lHdSMR
> JIT  - 20051027_1437_r8
> GC   - 20051020_AA)
> JCL  - 20051102
> 
> C:\perf>java Test
> OM avg was 32 (119723)
> JDOM avg was 32 (119723)
> 
> C:\perf>java Test
> OM avg was 27 (119723)
> JDOM avg was 23 (119723)
> 
> C:\perf>java Test
> OM avg was 26 (119723)
> JDOM avg was 22 (119723)
> 
> C:\perf>java Test
> OM avg was 24 (119723)
> JDOM avg was 22 (119723)
> 
> C:\perf>java Test
> OM avg was 29 (119723)
> JDOM avg was 21 (119723)
> 
> [SNIP]
> 
> C:\perf>java -version
> java version "1.4.2_09"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-b05)
> Java HotSpot(TM) Client VM (build 1.4.2_09-b05, mixed mode)
> 
> C:\perf>java Test
> OM avg was 50 (119723)
> JDOM avg was 45 (119723)
> 
> C:\perf>java Test
> OM avg was 49 (119723)
> JDOM avg was 47 (119723)
> 
> C:\perf>java Test
> OM avg was 51 (119723)
> JDOM avg was 45 (119723)
> 
> C:\perf>java Test
> OM avg was 50 (119723)
> JDOM avg was 45 (119723)
> 
> C:\perf>java Test
> OM avg was 49 (119723)
> JDOM avg was 47 (119723)



Mime
View raw message