Skip to content

Commit 650e9f9

Browse files
committed
improved jmh benchmark test, starts with profile jmh
1 parent 00503d9 commit 650e9f9

File tree

3 files changed

+61
-87
lines changed

3 files changed

+61
-87
lines changed

jbbp/pom.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,63 @@
5454
</dependencies>
5555

5656
<profiles>
57+
<profile>
58+
<id>jmh</id>
59+
<properties>
60+
<skipTests>true</skipTests>
61+
</properties>
62+
<build>
63+
<plugins>
64+
<plugin>
65+
<groupId>com.igormaznitsa</groupId>
66+
<artifactId>jbbp-maven-plugin</artifactId>
67+
<version>${project.version}</version>
68+
<executions>
69+
<execution>
70+
<id>generate-jbbp</id>
71+
<phase>generate-test-sources</phase>
72+
<goals>
73+
<goal>generate</goal>
74+
</goals>
75+
<configuration>
76+
<addToTestSourceFolders>true</addToTestSourceFolders>
77+
<source>${project.basedir}/src/test/jbbp</source>
78+
<output>${project.build.directory}/jbbp-test-generated</output>
79+
</configuration>
80+
</execution>
81+
</executions>
82+
</plugin>
83+
<plugin>
84+
<groupId>org.codehaus.mojo</groupId>
85+
<artifactId>exec-maven-plugin</artifactId>
86+
<executions>
87+
<execution>
88+
<id>run-benchmarks</id>
89+
<phase>test</phase>
90+
<goals>
91+
<goal>exec</goal>
92+
</goals>
93+
<configuration>
94+
<classpathScope>test</classpathScope>
95+
<executable>java</executable>
96+
<arguments>
97+
<argument>-classpath</argument>
98+
<classpath/>
99+
<argument>org.openjdk.jmh.Main</argument>
100+
<argument>.*</argument>
101+
<argument>-rf</argument>
102+
<argument>json</argument>
103+
<argument>-o</argument>
104+
<argument>${project.basedir}/jmh-out.txt</argument>
105+
</arguments>
106+
</configuration>
107+
</execution>
108+
</executions>
109+
</plugin>
110+
</plugins>
111+
</build>
112+
</profile>
113+
57114
<profile>
58115
<id>publish</id>
59116
<build>

jbbp/src/test/java/com/igormaznitsa/jbbp/benchmarks/JBBP_Benchmark.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*/
3434
public class JBBP_Benchmark {
3535

36-
private static final JBBPParser parser = JBBPParser.prepare("ubyte val; data [(val>>1)*(val+3)]{ bit:3 a; bit:3 b; bit:2 c; skip:1; }");
36+
private static final JBBPParser parser = JBBPParser.prepare("ubyte value; data [(value>>1)*(value+3)]{ bit:3 a; bit:3 b; bit:2 c; skip:1; }");
3737

3838
private static final Random RND = new Random(12345);
3939

@@ -46,12 +46,6 @@ public class JBBP_Benchmark {
4646
DATA[0] = (byte) val;
4747
}
4848

49-
public static void main(String... args) {
50-
System.out.println("-------------");
51-
System.out.println(parser.convertToSrc(TargetSources.JAVA_1_6, "com.igormaznitsa.jbbp.benchmarks.JBBP_Benchmark_Parser").get(0).getResult().values().iterator().next());
52-
System.out.println("-------------");
53-
}
54-
5549
@Benchmark
5650
public void measureParse_DynamicAndMapping() throws IOException {
5751
parser.parse(DATA).mapTo(Data.class);
@@ -64,7 +58,7 @@ public void measureParse_Dynamic() throws IOException {
6458

6559
@Benchmark
6660
public void measureParse_Static() throws IOException {
67-
new JBBP_Benchmark_Parser().read(new JBBPBitInputStream(new ByteArrayInputStream(DATA)));
61+
new JBBPBenchmarkParser().read(new JBBPBitInputStream(new ByteArrayInputStream(DATA)));
6862
}
6963

7064
public static class InData {
@@ -77,8 +71,8 @@ public static class InData {
7771
}
7872

7973
public static class Data {
80-
@Bin(name = "val", type = BinType.UBYTE)
81-
public int val;
74+
@Bin(name = "value", type = BinType.UBYTE)
75+
public int value;
8276

8377
@Bin(name = "data")
8478
public InData[] data;

jbbp/src/test/java/com/igormaznitsa/jbbp/benchmarks/JBBP_Benchmark_Parser.java

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)