Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example;
- import org.apache.zookeeper.KeeperException;
- 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.io.IOException;
- @SuppressWarnings({"PublicInnerClass", "PublicField"})
- //@BenchmarkMode(Mode.Throughput)
- @BenchmarkMode(Mode.AverageTime)
- @Warmup(iterations = 5)
- @Measurement(iterations = 5)
- @Fork(1)
- @State(Scope.Benchmark)
- public class PrivateMicrobenchmark {
- private MyClass.MyInnerClass testInstance;
- public static void main(String[] args) throws RunnerException {
- Options opt = new OptionsBuilder().include(PrivateMicrobenchmark.class.getSimpleName()).build();
- new Runner(opt).run();
- }
- @Setup(Level.Trial)
- public void setUp() throws InterruptedException, IOException, KeeperException {
- testInstance = MyClass$.MODULE$.createInner();
- }
- @Benchmark
- public Object getPrivate() throws KeeperException, InterruptedException {
- return testInstance.getPrivate();
- }
- @Benchmark
- public Object getPrivateThis() throws KeeperException, InterruptedException {
- return testInstance.getPrivateThis();
- }
- @Benchmark
- public Object setPrivate() throws KeeperException, InterruptedException {
- return testInstance.setPrivate();
- }
- @Benchmark
- public Object setPrivateThis() throws KeeperException, InterruptedException {
- return testInstance.setPrivateThis();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement