com.google.gwt.benchmarks.client
Class Benchmark

java.lang.Object
  extended by TestCase
      extended by com.google.gwt.junit.client.GWTTestCase
          extended by 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

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.


Nested Class Summary
static class Benchmark.BenchmarkStrategy
          The JUnitShell.Strategy used for benchmarking.
 
Nested classes/interfaces inherited from class com.google.gwt.junit.client.GWTTestCase
GWTTestCase.BaseStrategy, GWTTestCase.TestModuleInfo
 
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.
 
Fields inherited from class com.google.gwt.junit.client.GWTTestCase
ALL_GWT_TESTS
 
Constructor Summary
Benchmark()
           
 
Method Summary
 
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
 

Field Detail

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
Constructor Detail

Benchmark

public Benchmark()