Implements the JUnit
MethodRule interface for adding performance test
features to test calls.
for activating it, add an attribute of this class to your test class, e.g.:
public class SimpleTest {
@Rule
public ContiPerfRule i = new ContiPerfRule();
@Test
public void sleepAWhile() throws Exception {
Thread.sleep(100);
}
}
ContiPerf will then intercept each test method call and optionally cause
multiple invocations and check total execution time against a time limit.
invocation counts and time limits can be configured by Java annotations, e.g.
@Test(timeout = 300)
@PerfTest(invocations = 5, timeLimit = 500)
public void sleepALittleLonger() throws Exception {
System.out.print('x');
Thread.sleep(200);
}
For enabling different test settings, the invocation count values can be
configured in a properties file
contiperf.properties which
assigns the invocation count to the fully qualified method name, e.g.
org.databene.contiperf.junit.SimpleTest.sleepAWhile=3
org.databene.contiperf.junit.SimpleTest.sleepALittleLonger=2
If the properties file exists, it overrides the annotation values.
By default, the execution times are written to the CSV file
target/contiperf/contiperf.log. They have four columns, listing
the
- fully qualified method name
- total execution time
- invocation count
- start time in milliseconds since 1970-01-01
For reusing integration tests as performance tests, you can suppress
ContiPerf execution by setting the System property
contiperf.active=false.
Created: 12.10.2009 07:36:02