axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject svn commit: r292126 - in /webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf: ./ src/ src/org/ src/org/apache/ src/org/apache/perf/ src/org/apache/perf/sosnoski/ src/org/apache/perf/sosnoski/xmlbench/
Date Wed, 28 Sep 2005 05:10:29 GMT
Author: ajith
Date: Tue Sep 27 22:10:21 2005
New Revision: 292126

URL: http://svn.apache.org/viewcvs?rev=292126&view=rev
Log:
Adding the sosnoski benchmark source. Read the readme.txt for more information

Added:
    webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/readme.txt
    webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/
    webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/
    webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/
    webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/perf/
    webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/perf/sosnoski/
    webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/perf/sosnoski/xmlbench/
    webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/perf/sosnoski/xmlbench/BenchAXIOM.java

Added: webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/readme.txt
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/readme.txt?rev=292126&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/readme.txt (added)
+++ webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/readme.txt Tue Sep 27
22:10:21 2005
@@ -0,0 +1,2 @@
+The source contained here includes the bench marking code for AXIOM based on the XML bench
mark suit by Dennis Sosnoski (http://www.sosnoski.com/opensrc/xmlbench/index.html)
+For compliling and running the benchmark, the complete project at http://www.sosnoski.com/opensrc/xmlbench/code/fullbench.jar
needs to be downloaded.
\ No newline at end of file

Added: webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/perf/sosnoski/xmlbench/BenchAXIOM.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/perf/sosnoski/xmlbench/BenchAXIOM.java?rev=292126&view=auto
==============================================================================
--- webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/perf/sosnoski/xmlbench/BenchAXIOM.java
(added)
+++ webservices/axis2/trunk/archive/java/scratch/Ajith/sosnoski_perf/src/org/apache/perf/sosnoski/xmlbench/BenchAXIOM.java
Tue Sep 27 22:10:21 2005
@@ -0,0 +1,146 @@
+package org.apache.perf.sosnoski.xmlbench;
+
+import com.sosnoski.xmlbench.BenchDocBase;
+import com.sosnoski.xmlbench.DocumentSummary;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+
+import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
+import org.apache.axis2.om.*;
+
+import javax.xml.stream.*;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: Ajith
+ * Date: Sep 27, 2005
+ * Time: 11:48:36 AM
+ * To change this template use File | Settings | File Templates.
+ *
+ * The docbase code is somewhat simpleified because the
+ *
+ */
+public class BenchAXIOM extends BenchDocBase {
+
+    private OMFactory omFactory;
+
+    public BenchAXIOM() {
+        super("AXIOM");
+    }
+
+    protected Object build(InputStream in) {
+        //build the StaxOM builder
+        try {
+            XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(in);
+            if (omFactory==null){
+                  omFactory = OMAbstractFactory.getOMFactory();
+            }
+            StAXOMBuilder OMbuilder = new StAXOMBuilder(omFactory,reader);
+            return OMbuilder.getDocumentElement();
+        } catch (XMLStreamException ex) {
+            ex.printStackTrace(System.err);
+            System.exit(0);
+        }
+        return null;
+    }
+
+    /**
+     * Tree walker. trivial code to go through the child elements and feed it to
+     * the same procedure recursively
+     * @param doc
+     * @param summary
+     */
+    protected void walk(Object doc, DocumentSummary summary) {
+        //walk the elements
+        summary.addElements(1);
+        OMElement elt = (OMElement)doc;
+
+        //include the attributes
+        Iterator iter  =  elt.getAttributes();
+        while (iter.hasNext()) {
+            OMAttribute o = (OMAttribute)iter.next();
+            summary.addAttribute(o.getValue()==null?0:o.getValue().length());
+        }
+
+        //include the children
+        Iterator children = elt.getChildren();
+        while (children.hasNext()) {
+            OMNode o =  (OMNode)children.next();
+            if (o.getType()==OMNode.ELEMENT_NODE){
+                walk(o,summary);
+            }else if (o.getType()==OMNode.TEXT_NODE){
+                summary.addContent(((OMText)o).getText().length());
+            }else{
+                //todo - need to process the other events here as well
+            }
+
+        }
+    }
+
+    /**
+     * Write the output using the serialize method
+     * @param document
+     * @param out
+     */
+    protected void output(Object document, OutputStream out) {
+        try {
+            XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+            ((OMElement)document).serialize(writer);
+            writer.flush();
+        } catch (XMLStreamException ex) {
+            ex.printStackTrace(System.err);
+            System.exit(0);
+        }
+    }
+
+    /**
+     *  Modify a document representation. This method must be implemented by each
+	 * subclass to walk the document representation performing the following
+	 * modifications: remove all content segments which consist only of
+	 * whitespace; add an attribute "text" set to "true" to any elements which
+	 * directly contain non-whitespace text content; and replace each
+	 * non-whitespace text content segment with a "text" element which wraps
+	 * the content.
+     *
+     * @param document
+     */
+    protected void modify(Object document) {
+        OMElement elt  = (OMElement)document;
+        Iterator children = elt.getChildren();
+        boolean nonWhitespaceFound = false;
+        while (children.hasNext()) {
+            OMNode o =  (OMNode)children.next();
+            if (o.getType() == OMNode.TEXT_NODE){
+                // trim whitespace from content text
+                OMText text = (OMText)o;
+                String trimmed = ((OMText)o).getText().trim();
+                if (trimmed.length() != 0) {
+                    // wrap the trimmed content with new element. We've found
+                    //a non whitespace text content
+                    nonWhitespaceFound = true;
+                    OMElement parent = (OMElement) text.getParent();
+                    OMElement textElt = omFactory.createOMElement("text",elt.getNamespace());
+                    textElt.setText(trimmed);
+                    parent.addChild(textElt);
+                }else{
+                    //remove the text child.it's only a whitespace
+                    text.detach();
+                }
+            }else if (o.getType() == OMNode.ELEMENT_NODE){
+                modify(o);
+            }else{
+                //just hold still. don't do anything
+            }
+
+            if (nonWhitespaceFound){
+              elt.addAttribute("text","true",elt.getNamespace());  
+            }
+
+        }
+
+    }
+
+
+}



Mime
View raw message