Skip to content

Instantly share code, notes, and snippets.

@benelog
Created August 30, 2012 06:18
Show Gist options
  • Save benelog/3523197 to your computer and use it in GitHub Desktop.
Save benelog/3523197 to your computer and use it in GitHub Desktop.
Junit Benchmark
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.3</version>
</dependency>
<dependency>
<groupId>com.carrotsearch</groupId>
<artifactId>junit-benchmarks</artifactId>
<version>0.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.3.166</version>
<scope>test</scope>
</dependency>
import org.junit.Test;
import com.carrotsearch.junitbenchmarks.AbstractBenchmark;
import com.carrotsearch.junitbenchmarks.BenchmarkOptions;
import com.carrotsearch.junitbenchmarks.annotation.BenchmarkMethodChart;
/**
* @author benelog
*/
@BenchmarkMethodChart(filePrefix = "benchmark-sample")
public class SampleBenchmarkTest extends AbstractBenchmark {
@Test
@BenchmarkOptions(benchmarkRounds = 3, warmupRounds = 0)
public void test1() {
System.out.println("hello world1");
}
@Test
@BenchmarkOptions(benchmarkRounds = 3, warmupRounds = 0)
public void test2() {
System.out.println("hello world2");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment