💠

💠 2024-02-22 14:23:17


JMH

Official Site

Benchmark comparing serialization libraries on the JVM

简易Demo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    @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();

最佳实践