feat: JMHExample07
This commit is contained in:
parent
e9019278a4
commit
8dcec8d40c
|
@ -0,0 +1,40 @@
|
|||
package cn.bunny.jmh;
|
||||
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.Runner;
|
||||
import org.openjdk.jmh.runner.RunnerException;
|
||||
import org.openjdk.jmh.runner.options.Options;
|
||||
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@Fork(1)
|
||||
@Warmup(iterations = 5)
|
||||
@Measurement(iterations = 10)
|
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||
@State(Scope.Thread)
|
||||
public class JMHExample08 {
|
||||
|
||||
public static void main(String[] args) throws RunnerException {
|
||||
Options options = new OptionsBuilder()
|
||||
.include(JMHExample08.class.getSimpleName())
|
||||
.build();
|
||||
new Runner(options).run();
|
||||
}
|
||||
|
||||
// 禁止优化
|
||||
@CompilerControl(CompilerControl.Mode.EXCLUDE)
|
||||
@Benchmark
|
||||
public void test1() {
|
||||
|
||||
}
|
||||
|
||||
// 禁止优化
|
||||
@CompilerControl(CompilerControl.Mode.EXCLUDE)
|
||||
@Benchmark
|
||||
public void test2() {
|
||||
double log = Math.log(Math.PI);
|
||||
System.out.println(log);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue