|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.skeet.jbench.tasks.SimpleTask
Abstract class to make simple tasks easier to write. There are default no-op implementations for prepareTest and checkResults, getDescription returns something reasonable by default, and there's a single field, size, which is checked by default to be positive.
Subclasses are expected to write runTest methods of the form:
public void runTest()
{
long size = getSize();
for (long i=0; i < size; i++)
{
// insert code here
}
}
Quite a few tests of this form are useful, for instance testing the difference between StringBuffer.append() and String concatenation, where not a lot needs to be done first, but the test needs some kind of associated size. In some cases the size may be used for sizing a single test (eg the size of a vector to sort), in others it may be used for repeating a very short test several times (eg adding two floats or adding two doubles).
Constructor Summary | |
SimpleTask()
|
Method Summary | |
void |
checkConfiguration()
Checks that we have a positive size |
void |
checkResults()
Simple no-op implementation of checkResults. |
java.lang.String |
getDescription()
Default description which gives the name of the actual class and the number of iterations. |
protected long |
getSize()
Returns the number of size per test |
void |
prepareTest()
Simple no-op implementation of prepareTest. |
void |
setSize(long value)
Sets the number of size per test |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface uk.org.skeet.jbench.BenchTask |
runTest |
Constructor Detail |
public SimpleTask()
Method Detail |
public void setSize(long value)
protected long getSize()
public void checkConfiguration() throws ConfigurationException
checkConfiguration
in interface BenchTask
uk.org.skeet.jbench.BenchTask
ConfigurationException
- if the configuration specified is incomplete
or invalid.public void prepareTest() throws TaskException
prepareTest
in interface BenchTask
uk.org.skeet.jbench.BenchTask
TaskException
- if the preparation failed.public void checkResults() throws TaskException
checkResults
in interface BenchTask
uk.org.skeet.jbench.BenchTask
TaskException
- if the test failed.public java.lang.String getDescription()
getDescription
in interface BenchTask
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |