package org.openjdk; import org.openjdk.jmh.annotations.*; import java.util.concurrent.TimeUnit; @State(Scope.Thread) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Fork(5) public class ConstLengthBench { @Benchmark @CompilerControl(CompilerControl.Mode.DONT_INLINE) public int cmp1() { return "Aleksey Shipilev".length(); } @Benchmark @CompilerControl(CompilerControl.Mode.DONT_INLINE) public int cmp2() { return "Aleksey Shipilёv".length(); } }