Advertisement
slik1977

java

Feb 23rd, 2022
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. import org.openjdk.jmh.annotations.*;
  2. import org.openjdk.jmh.runner.options.Options;
  3. import org.openjdk.jmh.runner.options.OptionsBuilder;
  4.  
  5. import java.util.concurrent.TimeUnit;
  6. @State(Scope.Benchmark)
  7. public class Main {
  8.  
  9.     @Benchmark
  10.     @BenchmarkMode(Mode.SampleTime)
  11.     @Fork(warmups = 0, value = 1)
  12.     @Measurement(iterations = 10)
  13.     @OutputTimeUnit(TimeUnit.MICROSECONDS)
  14.     public void MergeSort(){
  15.         var ms = new MergeSort();
  16.         ms.ArraySort();
  17.     }
  18.  
  19.     @Benchmark
  20.     @BenchmarkMode(Mode.SampleTime)
  21.     @Fork(warmups = 0, value = 1)
  22.     @Measurement(iterations = 10)
  23.     @OutputTimeUnit(TimeUnit.MICROSECONDS)
  24.     public void QuickSort(){
  25.         var qs = new QuickSort();
  26.         qs.ArraySort();
  27.     }
  28.  
  29.     @Benchmark
  30.     @BenchmarkMode(Mode.SampleTime)
  31.     @Fork(warmups = 0, value = 1)
  32.     @Measurement(iterations = 10)
  33.     @OutputTimeUnit(TimeUnit.MICROSECONDS)
  34.     public void BubbleSort(){
  35.         var bs = new BubbleSort();
  36.         bs.ArraySort();
  37.     }
  38.     public static void main(String[] args) throws RuntimeException{
  39.         Options opt = new OptionsBuilder()
  40.                 .include(Main.class.getSimpleName())
  41.                 .forks(1)
  42.                 .build();
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement