com.sosnoski.xmlbench
Class BenchXPP
java.lang.Object
|
+--com.sosnoski.xmlbench.BenchBase
|
+--com.sosnoski.xmlbench.BenchDocBase
|
+--com.sosnoski.xmlbench.BenchXPP
- Direct Known Subclasses:
- BenchXPPBase, BenchXPPPull
- public abstract class BenchXPP
- extends BenchDocBase
Abstract base class for benchmarks measuring performance of the XPP
document representation. This base class implementation can be customized
by subclasses to experiment with options for the representation, in
particular for trying the pull node feature.
This code is based on a sample provided by Aleksander Slominski.
- Version:
- 1.2
- Author:
- Dennis M. Sosnoski
|
Field Summary |
protected org.gjt.xpp.XmlPullParserFactory |
m_parserFactory
Pull parser factory used within a test run. |
protected org.gjt.xpp.XmlRecorder |
m_recorder
XML recorder used within a test run. |
| Fields inherited from class com.sosnoski.xmlbench.BenchBase |
ATTRCHAR_COUNT_INDEX, ATTRIBUTE_COUNT_INDEX, AVERAGE_SPACE_INDEX, BUILD_AVERAGE_INDEX, BUILD_MIN_INDEX, CONTENT_COUNT_INDEX, DELTA_MEMORY_INDEX, ELEMENT_COUNT_INDEX, FIRST_SPACE_INDEX, GARBAGE_COLLECT_DELAY, GARBAGE_UNIT_DELAY, INITIAL_MEMORY_INDEX, m_configName, m_configVariant, m_lastMemory, m_lastTime, m_printPass, m_printStream, m_printSummary, MODIFY_AVERAGE_INDEX, MODIFY_MIN_INDEX, s_spaceFullDescriptions, s_spaceShortDescriptions, s_timeFullDescriptions, s_timeShortDescriptions, SERIALIZE_AVERAGE_INDEX, SERIALIZE_MIN_INDEX, SERIALIZE_SIZE_INDEX, SPACE_RESULT_COUNT, TEXT_AVERAGE_INDEX, TEXT_MIN_INDEX, TEXTCHAR_COUNT_INDEX, TIME_RESULT_COUNT, UNSERIALIZE_AVERAGE_INDEX, UNSERIALIZE_MIN_INDEX, WALK_AVERAGE_INDEX, WALK_MIN_INDEX, WALKED_SPACE_INDEX |
|
Constructor Summary |
protected |
BenchXPP(java.lang.String config)
Constructor. |
|
Method Summary |
protected void |
modify(java.lang.Object doc)
Modify a document representation. |
protected void |
modifyElement(org.gjt.xpp.XmlNode element)
Modify subtree for element. |
protected void |
output(java.lang.Object doc,
java.io.OutputStream out)
Output a document as XML text. |
protected void |
reset()
Reset test class instance. |
protected void |
walk(java.lang.Object doc,
DocumentSummary summary)
Walk and summarize document. |
protected void |
walkElement(org.gjt.xpp.XmlNode element,
DocumentSummary summary)
Walk subtree for element. |
| Methods inherited from class com.sosnoski.xmlbench.BenchBase |
getName, initMemory, initTime, printSummary, reportSpace, reportTime, reportValue, setPrint, setShowDocument, setShowPass, setVariant, testPassSpace, testPassTime |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_parserFactory
protected org.gjt.xpp.XmlPullParserFactory m_parserFactory
- Pull parser factory used within a test run.
m_recorder
protected org.gjt.xpp.XmlRecorder m_recorder
- XML recorder used within a test run.
BenchXPP
protected BenchXPP(java.lang.String config)
- Constructor.
- Parameters:
config - test configuration name
walkElement
protected void walkElement(org.gjt.xpp.XmlNode element,
DocumentSummary summary)
- Walk subtree for element. This recursively walks through the document
nodes under an element, accumulating summary information.
- Parameters:
element - element to be walkedsummary - document summary information
walk
protected void walk(java.lang.Object doc,
DocumentSummary summary)
- Walk and summarize document. This method walks through the nodes
of the document, accumulating summary information.
- Overrides:
walk in class BenchDocBase
- Parameters:
doc - document representation to be walkedsummary - output document summary information
output
protected void output(java.lang.Object doc,
java.io.OutputStream out)
- Output a document as XML text. This implementation uses the method
defined by XPP to output a text representation of the document.
- Overrides:
output in class BenchDocBase
- Parameters:
doc - document representation to be outputout - XML document output stream
modifyElement
protected void modifyElement(org.gjt.xpp.XmlNode element)
throws org.gjt.xpp.XmlPullParserException
- Modify subtree for element. This recursively walks through the document
nodes under an element, performing the modifications.
- Parameters:
element - element to be walked- Throws:
org.gjt.xpp.XmlPullParserException - on error walking tree
modify
protected void modify(java.lang.Object doc)
- Modify a document representation. This implementation of the abstract
superclass method walks 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 trimmed content.
- Overrides:
modify in class BenchDocBase
- Parameters:
doc - document representation to be modified
reset
protected void reset()
- Reset test class instance. This discards the parser factory and recorder
used within a test pass.
- Overrides:
reset in class BenchDocBase