com.sosnoski.xmlbench
Class BenchBase

java.lang.Object
  |
  +--com.sosnoski.xmlbench.BenchBase
Direct Known Subclasses:
BenchDocBase, BenchSAX

public abstract class BenchBase
extends java.lang.Object

Base class for XML benchmark tests. This class provides some basic methods used by the testing. It must be subclassed for each particular parser or document representation to be tested.

Version:
1.2
Author:
Dennis M. Sosnoski

Field Summary
static int ATTRCHAR_COUNT_INDEX
          Attribute character count index.
static int ATTRIBUTE_COUNT_INDEX
          Attribute count index.
static int AVERAGE_SPACE_INDEX
          Last document memory usage.
static int BUILD_AVERAGE_INDEX
          Average document build time result index.
static int BUILD_MIN_INDEX
          Best document build time result index.
static int CONTENT_COUNT_INDEX
          Content text segment count index.
static int DELTA_MEMORY_INDEX
          Net change in memory usage from start to end.
static int ELEMENT_COUNT_INDEX
          Element count index.
static int FIRST_SPACE_INDEX
          First document memory usage.
static long GARBAGE_COLLECT_DELAY
          Total interval in milliseconds to wait for garbage collection.
static long GARBAGE_UNIT_DELAY
          Interval in milliseconds to wait each time.
static int INITIAL_MEMORY_INDEX
          Initial memory usage (before document construction).
protected  java.lang.String m_configName
          Name for this test configuration.
protected  java.lang.String m_configVariant
          Optional variant information for test configuration.
protected static long m_lastMemory
          Memory usage at start of test.
protected static long m_lastTime
          Time at start of test.
protected  boolean m_printPass
          Flag for printing detailed pass results.
protected  java.io.PrintStream m_printStream
          Destination for test results listing.
protected  boolean m_printSummary
          Flag for printing document summary information.
static int MODIFY_AVERAGE_INDEX
          Average modification time result index.
static int MODIFY_MIN_INDEX
          Best modification time result index.
static java.lang.String[] s_spaceFullDescriptions
          Full descriptions of space test result values.
static java.lang.String[] s_spaceShortDescriptions
          Abbreviated descriptions of space test result values.
static java.lang.String[] s_timeFullDescriptions
          Full descriptions of time test result values.
static java.lang.String[] s_timeShortDescriptions
          Abbreviated descriptions of time test result values.
static int SERIALIZE_AVERAGE_INDEX
          Average serialization time result index.
static int SERIALIZE_MIN_INDEX
          Best serialization time result index.
static int SERIALIZE_SIZE_INDEX
          Serialized size result index.
static int SPACE_RESULT_COUNT
          Count of result values returned.
static int TEXT_AVERAGE_INDEX
          Average document text generation time result index.
static int TEXT_MIN_INDEX
          Best document text generation time result index.
static int TEXTCHAR_COUNT_INDEX
          Text character count index.
static int TIME_RESULT_COUNT
          Count of result values returned.
static int UNSERIALIZE_AVERAGE_INDEX
          Average unserialization time walk time result index.
static int UNSERIALIZE_MIN_INDEX
          Best unserialization time walk time result index.
static int WALK_AVERAGE_INDEX
          Average document walk time result index.
static int WALK_MIN_INDEX
          Best document walk time result index.
static int WALKED_SPACE_INDEX
          Memory usage change after walking document.
 
Constructor Summary
protected BenchBase(java.lang.String config)
          Constructor.
 
Method Summary
 java.lang.String getName()
          Get configuration name.
protected  void initMemory()
          Initializes the memory state prior to a test run.
protected  void initTime()
          Initializes the time prior to a test run.
protected  void printSummary(java.lang.String lead, DocumentSummary info, java.io.PrintStream print)
          Print document summary information.
protected  int reportSpace(java.lang.String test)
          Report the results of a memory test run.
protected  int reportTime(java.lang.String test)
          Report the results of a time test run.
protected  void reportValue(java.lang.String lead, int value)
          Report a value.
abstract  int[] runSpaceTest(int passes, int excludes, byte[][] texts)
          Main space test method.
abstract  int[] runTimeTest(int passes, int excludes, byte[][] texts)
          Main time test method.
 void setPrint(java.io.PrintStream print)
          Set output print stream for printing detailed test run results.
 void setShowDocument(boolean show)
          Set flag for printing document summary information.
 void setShowPass(boolean show)
          Set flag for printing individual test pass results.
protected  void setVariant(java.lang.String variant)
          Set configuration variant information.
protected  int testPassSpace()
          Find test pass space.
protected  int testPassTime()
          Find test pass time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUILD_MIN_INDEX

public static final int BUILD_MIN_INDEX
Best document build time result index.

BUILD_AVERAGE_INDEX

public static final int BUILD_AVERAGE_INDEX
Average document build time result index.

WALK_MIN_INDEX

public static final int WALK_MIN_INDEX
Best document walk time result index.

WALK_AVERAGE_INDEX

public static final int WALK_AVERAGE_INDEX
Average document walk time result index.

TEXT_MIN_INDEX

public static final int TEXT_MIN_INDEX
Best document text generation time result index.

TEXT_AVERAGE_INDEX

public static final int TEXT_AVERAGE_INDEX
Average document text generation time result index.

SERIALIZE_MIN_INDEX

public static final int SERIALIZE_MIN_INDEX
Best serialization time result index.

SERIALIZE_AVERAGE_INDEX

public static final int SERIALIZE_AVERAGE_INDEX
Average serialization time result index.

UNSERIALIZE_MIN_INDEX

public static final int UNSERIALIZE_MIN_INDEX
Best unserialization time walk time result index.

UNSERIALIZE_AVERAGE_INDEX

public static final int UNSERIALIZE_AVERAGE_INDEX
Average unserialization time walk time result index.

MODIFY_MIN_INDEX

public static final int MODIFY_MIN_INDEX
Best modification time result index.

MODIFY_AVERAGE_INDEX

public static final int MODIFY_AVERAGE_INDEX
Average modification time result index.

SERIALIZE_SIZE_INDEX

public static final int SERIALIZE_SIZE_INDEX
Serialized size result index.

ELEMENT_COUNT_INDEX

public static final int ELEMENT_COUNT_INDEX
Element count index.

CONTENT_COUNT_INDEX

public static final int CONTENT_COUNT_INDEX
Content text segment count index.

ATTRIBUTE_COUNT_INDEX

public static final int ATTRIBUTE_COUNT_INDEX
Attribute count index.

TEXTCHAR_COUNT_INDEX

public static final int TEXTCHAR_COUNT_INDEX
Text character count index.

ATTRCHAR_COUNT_INDEX

public static final int ATTRCHAR_COUNT_INDEX
Attribute character count index.

TIME_RESULT_COUNT

public static final int TIME_RESULT_COUNT
Count of result values returned.

INITIAL_MEMORY_INDEX

public static final int INITIAL_MEMORY_INDEX
Initial memory usage (before document construction).

DELTA_MEMORY_INDEX

public static final int DELTA_MEMORY_INDEX
Net change in memory usage from start to end.

FIRST_SPACE_INDEX

public static final int FIRST_SPACE_INDEX
First document memory usage.

AVERAGE_SPACE_INDEX

public static final int AVERAGE_SPACE_INDEX
Last document memory usage.

WALKED_SPACE_INDEX

public static final int WALKED_SPACE_INDEX
Memory usage change after walking document.

SPACE_RESULT_COUNT

public static final int SPACE_RESULT_COUNT
Count of result values returned.

s_timeShortDescriptions

public static final java.lang.String[] s_timeShortDescriptions
Abbreviated descriptions of time test result values.

s_timeFullDescriptions

public static final java.lang.String[] s_timeFullDescriptions
Full descriptions of time test result values.

s_spaceShortDescriptions

public static final java.lang.String[] s_spaceShortDescriptions
Abbreviated descriptions of space test result values.

s_spaceFullDescriptions

public static final java.lang.String[] s_spaceFullDescriptions
Full descriptions of space test result values.

GARBAGE_COLLECT_DELAY

public static final long GARBAGE_COLLECT_DELAY
Total interval in milliseconds to wait for garbage collection.

GARBAGE_UNIT_DELAY

public static final long GARBAGE_UNIT_DELAY
Interval in milliseconds to wait each time.

m_lastMemory

protected static long m_lastMemory
Memory usage at start of test.

m_lastTime

protected static long m_lastTime
Time at start of test.

m_configName

protected final java.lang.String m_configName
Name for this test configuration.

m_configVariant

protected java.lang.String m_configVariant
Optional variant information for test configuration.

m_printStream

protected java.io.PrintStream m_printStream
Destination for test results listing.

m_printSummary

protected boolean m_printSummary
Flag for printing document summary information.

m_printPass

protected boolean m_printPass
Flag for printing detailed pass results.
Constructor Detail

BenchBase

protected BenchBase(java.lang.String config)
Constructor.
Parameters:
config - test configuration name
Method Detail

initMemory

protected void initMemory()
Initializes the memory state prior to a test run. This method first requests a garbage collection operation, then waits for a fixed interval in order to encourage the JVM to do the collection. It also sets the start of test value for memory usage.

initTime

protected void initTime()
Initializes the time prior to a test run. This method justs sets the start of test time from the system clock.

reportValue

protected void reportValue(java.lang.String lead,
                           int value)
Report a value. Prints the leading text and the value with a space between, if printing is enabled.
Parameters:
lead - leading text for test results
value - value to be printed

testPassTime

protected int testPassTime()
Find test pass time. Besides returning the time for the last test pass, this sets the current time as the start of the next test pass.
Returns:
milliseconds taken for the test

testPassSpace

protected int testPassSpace()
Find test pass space. Besides returning the space for the last test pass, this sets the current space usage as the start of the next test pass.
Returns:
bytes of memory added by test pass (negative if space released)

reportTime

protected int reportTime(java.lang.String test)
Report the results of a time test run. Prints the time taken for the last test and sets the current time as the start time for the next test.
Parameters:
test - test description for display
Returns:
milliseconds taken for the test

reportSpace

protected int reportSpace(java.lang.String test)
Report the results of a memory test run. First attempts a garbage collection operation before computing the difference between the memory in use at the end of the test and that in use at the start of the test. Prints the space used by the test and sets the current space as the base for the next test.
Parameters:
test - test description for display
Returns:
space used by test

printSummary

protected void printSummary(java.lang.String lead,
                            DocumentSummary info,
                            java.io.PrintStream print)
Print document summary information. Prints the information with a supplied lead phrase.
Parameters:
lead - lead text phrase for document summary
info - document summary information
print - stream on which to print

getName

public java.lang.String getName()
Get configuration name. Returns the name of the document model used by this test, with any supplied variant information appended in parenthesis.
Returns:
document model name

setVariant

protected void setVariant(java.lang.String variant)
Set configuration variant information. This may be used by subclasses which need to deal with several variations of a single configuration.
Parameters:
variant - configuration variant description, appended to name

setPrint

public void setPrint(java.io.PrintStream print)
Set output print stream for printing detailed test run results.
Parameters:
print - test results listing destination (null if no listing output)

setShowDocument

public void setShowDocument(boolean show)
Set flag for printing document summary information.
Parameters:
show - flag for document summary information to be printed

setShowPass

public void setShowPass(boolean show)
Set flag for printing individual test pass results.
Parameters:
show - flag for document summary information to be printed

runTimeTest

public abstract int[] runTimeTest(int passes,
                                  int excludes,
                                  byte[][] texts)
Main time test method. This must be implemented by the subclass to perform the sequence of speed tests appropriate to the test platform.
Parameters:
passes - number of passes of each test
excludes - number of initialization passes excluded from averages
texts - document texts for test
Returns:
result times array

runSpaceTest

public abstract int[] runSpaceTest(int passes,
                                   int excludes,
                                   byte[][] texts)
Main space test method. This must be implemented by the subclass to perform the sequence of space tests appropriate to the test platform.
Parameters:
passes - number of passes of each test
excludes - number of initialization passes excluded from averages
texts - document texts for test
Returns:
result spaces array


Company Web Site

XML Benchmark Home