Advertisement
Guest User

Untitled

a guest
May 9th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. package com.example;
  2.  
  3. import org.apache.zookeeper.KeeperException;
  4. import org.openjdk.jmh.annotations.*;
  5. import org.openjdk.jmh.runner.Runner;
  6. import org.openjdk.jmh.runner.RunnerException;
  7. import org.openjdk.jmh.runner.options.Options;
  8. import org.openjdk.jmh.runner.options.OptionsBuilder;
  9.  
  10. import java.io.IOException;
  11.  
  12. @SuppressWarnings({"PublicInnerClass", "PublicField"})
  13. //@BenchmarkMode(Mode.Throughput)
  14. @BenchmarkMode(Mode.AverageTime)
  15. @Warmup(iterations = 5)
  16. @Measurement(iterations = 5)
  17. @Fork(1)
  18. @State(Scope.Benchmark)
  19. public class PrivateMicrobenchmark {
  20.     private MyClass.MyInnerClass testInstance;
  21.  
  22.     public static void main(String[] args) throws RunnerException {
  23.         Options opt = new OptionsBuilder().include(PrivateMicrobenchmark.class.getSimpleName()).build();
  24.         new Runner(opt).run();
  25.     }
  26.  
  27.     @Setup(Level.Trial)
  28.     public void setUp() throws InterruptedException, IOException, KeeperException {
  29.         testInstance = MyClass$.MODULE$.createInner();
  30.     }
  31.  
  32.     @Benchmark
  33.     public Object getPrivate() throws KeeperException, InterruptedException {
  34.         return testInstance.getPrivate();
  35.     }
  36.  
  37.     @Benchmark
  38.     public Object getPrivateThis() throws KeeperException, InterruptedException {
  39.         return testInstance.getPrivateThis();
  40.     }
  41.  
  42.     @Benchmark
  43.     public Object setPrivate() throws KeeperException, InterruptedException {
  44.         return testInstance.setPrivate();
  45.     }
  46.  
  47.     @Benchmark
  48.     public Object setPrivateThis() throws KeeperException, InterruptedException {
  49.         return testInstance.setPrivateThis();
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement