11package ru .javaops .masterjava .matrix ;
22
33import org .openjdk .jmh .annotations .*;
4+ import org .openjdk .jmh .runner .Runner ;
5+ import org .openjdk .jmh .runner .RunnerException ;
6+ import org .openjdk .jmh .runner .options .Options ;
7+ import org .openjdk .jmh .runner .options .OptionsBuilder ;
8+ import org .openjdk .jmh .runner .options .TimeValue ;
49
510import java .util .concurrent .ExecutorService ;
611import java .util .concurrent .Executors ;
1621@ OutputTimeUnit (TimeUnit .MILLISECONDS )
1722@ State (Scope .Benchmark )
1823@ Threads (1 )
19- @ Fork (1 )
24+ @ Fork (10 )
2025@ Timeout (time = 5 , timeUnit = TimeUnit .MINUTES )
2126public class MatrixBenchmark {
2227 // Matrix size
23- @ Param ({"100" , " 1000" })
28+ @ Param ({"1000" })
2429 private int matrixSize ;
2530
2631 private static final int THREAD_NUMBER = 10 ;
@@ -35,12 +40,22 @@ public void setUp() {
3540 matrixB = MatrixUtil .create (matrixSize );
3641 }
3742
38- @ Benchmark
43+ public static void main (String [] args ) throws RunnerException {
44+ Options options = new OptionsBuilder ()
45+ .include (MatrixBenchmark .class .getSimpleName ())
46+ .threads (1 )
47+ .forks (10 )
48+ .timeout (TimeValue .minutes (5 ))
49+ .build ();
50+ new Runner (options ).run ();
51+ }
52+
53+ // @Benchmark
3954 public int [][] singleThreadMultiplyOpt () throws Exception {
4055 return MatrixUtil .singleThreadMultiplyOpt (matrixA , matrixB );
4156 }
4257
43- @ Benchmark
58+ // @Benchmark
4459 public int [][] concurrentMultiplyStreams () throws Exception {
4560 return MatrixUtil .concurrentMultiplyStreams (matrixA , matrixB , executor );
4661 }
0 commit comments