Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 60390 invoked from network); 30 Mar 2006 21:12:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Mar 2006 21:12:39 -0000 Received: (qmail 48219 invoked by uid 500); 30 Mar 2006 21:12:36 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 48175 invoked by uid 500); 30 Mar 2006 21:12:36 -0000 Mailing-List: contact axis-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@ws.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-dev@ws.apache.org Received: (qmail 48164 invoked by uid 99); 30 Mar 2006 21:12:36 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Mar 2006 13:12:36 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [206.123.75.163] (HELO sosnoski.com) (206.123.75.163) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Mar 2006 13:12:34 -0800 Received: from [192.168.0.2] (222-152-132-196.jetstream.xtra.co.nz [222.152.132.196]) (authenticated bits=0) by sosnoski.com (8.12.10/8.12.10) with ESMTP id k2ULC58C009356 for ; Thu, 30 Mar 2006 16:12:10 -0500 Message-ID: <442C49A2.8000007@sosnoski.com> Date: Fri, 31 Mar 2006 09:12:02 +1200 From: Dennis Sosnoski User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050322) X-Accept-Language: en-us, en MIME-Version: 1.0 To: axis-dev@ws.apache.org Subject: Re: [Axis2] AXIOM vs. JDOM trivial perf test References: <442C0D24.1090501@thoughtcraft.com> <19e0530f0603301216r2b0c161o2caae87635100772@mail.gmail.com> In-Reply-To: <19e0530f0603301216r2b0c161o2caae87635100772@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N You might want to just add this on to the one I created, Glen: http://issues.apache.org/jira/browse/AXIS2-533 I include JDOM in my test code there (using the Piccolo SAX parser), but didn't discuss the JDOM results in the text since dom4j is generally faster and smaller. - Dennis Davanum Srinivas wrote: >Glen, > >Could up please send the bigfile.xml as well? Better to do it via JIRA. > >thanks, >dims > >On 3/30/06, Glen Daniels 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/ > > >