Skip to content

Commit 8a25fb1

Browse files
committed
2 05 JMH main jar
1 parent 2697614 commit 8a25fb1

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

pom.xml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,41 @@
3030
<target>${java.version}</target>
3131
</configuration>
3232
</plugin>
33+
<plugin>
34+
<groupId>org.apache.maven.plugins</groupId>
35+
<artifactId>maven-shade-plugin</artifactId>
36+
<version>3.1.0</version>
37+
<executions>
38+
<execution>
39+
<phase>package</phase>
40+
<goals>
41+
<goal>shade</goal>
42+
</goals>
43+
<configuration>
44+
<finalName>benchmarks</finalName>
45+
<transformers>
46+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
47+
<mainClass>org.openjdk.jmh.Main</mainClass>
48+
</transformer>
49+
</transformers>
50+
<filters>
51+
<filter>
52+
<!--
53+
Shading signed JARs will fail without this.
54+
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
55+
-->
56+
<artifact>*:*</artifact>
57+
<excludes>
58+
<exclude>META-INF/*.SF</exclude>
59+
<exclude>META-INF/*.DSA</exclude>
60+
<exclude>META-INF/*.RSA</exclude>
61+
</excludes>
62+
</filter>
63+
</filters>
64+
</configuration>
65+
</execution>
66+
</executions>
67+
</plugin>
3368
</plugins>
3469
</build>
3570

src/main/java/ru/javaops/masterjava/matrix/MatrixBenchmark.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package ru.javaops.masterjava.matrix;
22

33
import 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

510
import java.util.concurrent.ExecutorService;
611
import java.util.concurrent.Executors;
@@ -33,6 +38,16 @@ public void setUp() {
3338

3439
private ExecutorService executor;
3540

41+
public static void main(String[] args) throws RunnerException {
42+
Options options = new OptionsBuilder()
43+
.include(MatrixBenchmark.class.getSimpleName())
44+
.threads(1)
45+
.forks(10)
46+
.timeout(TimeValue.minutes(5))
47+
.build();
48+
new Runner(options).run();
49+
}
50+
3651
// @Benchmark
3752
public int[][] singleThreadMultiplyOpt() throws Exception {
3853
return MatrixUtil.singleThreadMultiplyOpt(matrixA, matrixB);

0 commit comments

Comments
 (0)