JUnitBenchmarks:

Build Integration

Maven

For Mavenized projects, little needs to be done. Simply add the dependency on junit-benchmarks to POM's dependencies:

<dependency>
    <groupId>com.carrotsearch</groupId>
    <artifactId>junit-benchmarks</artifactId>
    <version>0.7.2</version>
    <scope>test</scope>
</dependency>

Stable releases are pushed to Maven Central (up from version 0.2.1). Snapshot and release versions are available from SonaType's public Maven repositories:

<repositories>
    <repository>
        <id>sonatype-nexus-public</id>
        <name>SonaType public snapshots and releases repository</name>
        <url>https://oss.sonatype.org/content/groups/public</url>
        <releases> 
            <!-- set to true if you wish to fetch releases from this repo too. -->
            <enabled>false</enabled>
        </releases> 
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

Once completed, your tests can start using benchmarking annotations.

For charts and H2 results persistence, an additional dependency on H2 must be added to your project (it is an optional dependency in junit-benchmark's POM.

ANT

Integration with ANT requires you to download a junit-benchmark release (or build it from sources). As with Maven, H2 needs to be downloaded separately, if it's to be used.

Then, you can simply create a path reference to the above JAR files:

<path id="jub">
    <fileset dir="lib">
      <include name="junit-benchmarks*.jar" />
      <include name="h2*.jar" />
</path>

and reference this path from junit or javac tasks.

Run your tests with fork attribute set to true and forkmode set to once. This ensures the test database is properly closed once the tests complete.