Jade Dungeon

JMH

基准测试工具JMH

例子:

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Scope;

@State(Scope.Benchmark)
public class CityToCountBenchmark {

	@Benchmark
	public void synchronizedHashMap() {
		String name = Thread.currentThread().getName();
		appService1.doJob(name, name + "2");

	}

	@Benchmark
	public void concurrentHashMap() {
		String name = Thread.currentThread().getName();
		appService2.doJob(name, name + "2");
	}

}