Loading...

Harness benchmarks for Java

JMH is a Java harness for building, running, and analysing nano/micro/milli/macro benchmarks written in Java and other languages targeting the JVM.

http://openjdk.java.net/projects/code-tools/jmh/

Add the maven coordinates to your Maven pom.xml

<dependency>
	<groupId>org.openjdk.jmh</groupId>
	<artifactId>jmh-core</artifactId>
	<version>1.11</version>
</dependency>

You can clone the source Repository http://hg.openjdk.java.net/code-tools/jmh/

hg clone http://hg.openjdk.java.net/code-tools/jmh

Benchmark parts of your code by using annotations

@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public void processPayment(MoneyTransaction trx){
  //..
}

See also http://www.oracle.com/technetwork/articles/java/architect-benchmarking-2266277.html