com.google.gwt.benchmarks.client
Class Benchmark
java.lang.Object
TestCase
com.google.gwt.junit.client.GWTTestCase
com.google.gwt.benchmarks.client.Benchmark
public abstract class Benchmark
- extends GWTTestCase
A type of GWTTestCase which specifically
records performance results. Benchmarks have additional functionality
above and beyond GWT's JUnit support for standard TestCases.
Reporting
In a single JUnit run, the results of all executed benchmarks
are collected and stored in an XML report viewable with the
benchmarkViewer.
Permutations
GWT supports test methods that have parameters. GWT will execute each
benchmark method multiple times in order to exhaustively test all the
possible combinations of parameter values. All of your test method parameters
must be annotated with a Range annotation such as RangeField
or RangeEnum.
For example,
public void testArrayListRemoves(
@RangeEnum(Position.class) Position where,
@RangeField("insertRemoveRange") Integer size) { ...
}
Timing
- GWT automatically removes jitter from your benchmark methods by running
them for a minimum period of time (150ms).
- GWT supports
time limits on the maximum
duration of each permutation of a benchmark method. With this feature, you
can supply very high upper bounds on your ranges (such as Integer.MAX_VALUE),
which future-proofs your benchmarks against faster hardware.
- GWT supports
Setup and Teardown methods which separate
test overhead from the actual work being benchmarked. The timings of these
lifecycle methods are excluded from test results.
Notes
Please note that Benchmarks do not currently support asynchronous
testing mode. Calling
GWTTestCase.delayTestFinish(int) or
GWTTestCase.finishTest() will result in
an UnsupportedOperationException.
Examples of benchmarking in action
A simple benchmark example
AllocBenchmark is an example of a basic benchmark that doesn't
take advantage of most of benchmarking's advanced features.
An advanced benchmark example
ArrayListBenchmark is a more sophisticated example of
benchmarking. It demonstrates the use of Setup and Teardown
test methods, parameterized test methods, and time limits.
|
Field Summary |
static java.lang.String |
REPORT_PATH
The name of the system property that specifies the location where benchmark
reports are both written to and read from. |
| Methods inherited from class com.google.gwt.junit.client.GWTTestCase |
addCheckpoint, catchExceptions, clearCheckpoints, getAllTestModuleNames, getCheckpoints, getModuleCount, getModuleName, getStrategy, getSyntheticModuleName, getTestsForModule, isPureJava, run, setForcePureJava, setName |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
REPORT_PATH
public static final java.lang.String REPORT_PATH
- The name of the system property that specifies the location where benchmark
reports are both written to and read from. Its value is
com.google.gwt.junit.reportPath.
If this system property is not set, the path defaults to the user's current
working directory.
- See Also:
- Constant Field Values
Benchmark
public Benchmark()