Skip to content
kcp edited this page Jul 13, 2020 · 1 revision

title: JMH date: 2020-05-06 01:44:38 tags: categories:

目录 start

  1. JMH
    1. 简易Demo
    2. 最佳实践

目录 end|2020-05-06 01:45|


JMH

Official Site

参考: Java微基准测试框架JMH

Benchmark comparing serialization libraries on the JVM

简易Demo

    @BenchmarkMode(Mode.Throughput)
    @Warmup(iterations = 5)
    @Measurement(iterations = 10, time = 1)
    @Threads(2)
    @OutputTimeUnit(TimeUnit.MILLISECONDS)
    class Target{
        @Benchmark
        public void max(){

        }
    }

    // 运行 JMH
    new Runner(new OptionsBuilder().include(Target.class.getSimpleName()).build()).run();

最佳实践

Summary

Clone this wiki locally