Improvements in InMemoryDataTree benchmarking. 52/10852/1
authorLukas Sedlak <lsedlak@cisco.com>
Fri, 5 Sep 2014 14:03:16 +0000 (16:03 +0200)
committerLukas Sedlak <lsedlak@cisco.com>
Fri, 5 Sep 2014 14:03:16 +0000 (16:03 +0200)
Added profile "benchmarks" into Yangtools parent pom to automatically run benchmarks with Yangtools build.
Added maven build plugin into benchmarks project for running JMH benchmarks via Maven execution.
Added minor changes to specify Fork and Warmup counts for InMemoryDataTree benchmark.

Change-Id: I8897a75a1cbed6a16fab13c8b7b4d68e61d88db6
Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
benchmarks/pom.xml
benchmarks/src/main/java/org/opendaylight/yangtools/yang/data/impl/tree/InMemoryDataTreeBenchmark.java
pom.xml

index e80bfee9f9e19757899026c7319b8d0b70dd55b6..83805cf10dc91f42dc5427f1f07e92dbc4c6b340 100644 (file)
           <target>${java.source.version}</target>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <configuration>
+          <classpathScope>test</classpathScope>
+          <executable>java</executable>
+          <arguments>
+            <argument>-classpath</argument>
+            <classpath/>
+            <argument>org.openjdk.jmh.Main</argument>
+            <argument>.*</argument>
+          </arguments>
+        </configuration>
+        <executions>
+          <execution>
+            <id>run-benchmarks</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>
index a9171687cfc29b5aed112cc81651abc9f0817daf..4cf95a73acb889b5ef9f066661f85c33ba63452b 100644 (file)
@@ -38,8 +38,12 @@ import org.openjdk.jmh.runner.options.OptionsBuilder;
 @State(Scope.Thread)
 @BenchmarkMode(Mode.AverageTime)
 @OutputTimeUnit(TimeUnit.MILLISECONDS)
+@Fork(1)
 public class InMemoryDataTreeBenchmark {
 
+    private static final int WARMUP_ITERATIONS = 20;
+    private static final int MEASUREMENT_ITERATIONS = 20;
+
     private static final int OUTER_LIST_100K = 100000;
     private static final int OUTER_LIST_50K = 50000;
     private static final int OUTER_LIST_10K = 10000;
@@ -139,8 +143,8 @@ public class InMemoryDataTreeBenchmark {
     }
 
     @Benchmark
-    @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS)
-    @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS)
+    @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
+    @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
     public void write100KSingleNodeWithOneInnerItemInOneCommitBenchmark() throws Exception {
         final DataTreeSnapshot snapshot = datastore.takeSnapshot();
         final DataTreeModification modification = snapshot.newModification();
@@ -153,8 +157,8 @@ public class InMemoryDataTreeBenchmark {
     }
 
     @Benchmark
-    @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS)
-    @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS)
+    @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
+    @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
     public void write100KSingleNodeWithOneInnerItemInCommitPerWriteBenchmark() throws Exception {
         final DataTreeSnapshot snapshot = datastore.takeSnapshot();
         for (int outerListKey = 0; outerListKey < OUTER_LIST_100K; ++outerListKey) {
@@ -167,8 +171,8 @@ public class InMemoryDataTreeBenchmark {
     }
 
     @Benchmark
-    @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS)
-    @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS)
+    @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
+    @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
     public void write50KSingleNodeWithTwoInnerItemsInOneCommitBenchmark() throws Exception {
         final DataTreeSnapshot snapshot = datastore.takeSnapshot();
         final DataTreeModification modification = snapshot.newModification();
@@ -181,8 +185,8 @@ public class InMemoryDataTreeBenchmark {
     }
 
     @Benchmark
-    @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS)
-    @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS)
+    @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
+    @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
     public void write50KSingleNodeWithTwoInnerItemsInCommitPerWriteBenchmark() throws Exception {
         final DataTreeSnapshot snapshot = datastore.takeSnapshot();
         for (int outerListKey = 0; outerListKey < OUTER_LIST_50K; ++outerListKey) {
@@ -195,8 +199,8 @@ public class InMemoryDataTreeBenchmark {
     }
 
     @Benchmark
-    @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS)
-    @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS)
+    @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
+    @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
     public void write10KSingleNodeWithTenInnerItemsInOneCommitBenchmark() throws Exception {
         final DataTreeSnapshot snapshot = datastore.takeSnapshot();
         final DataTreeModification modification = snapshot.newModification();
@@ -209,8 +213,8 @@ public class InMemoryDataTreeBenchmark {
     }
 
     @Benchmark
-    @Warmup(iterations = 10, timeUnit = TimeUnit.MILLISECONDS)
-    @Measurement(iterations = 20, timeUnit = TimeUnit.MILLISECONDS)
+    @Warmup(iterations = WARMUP_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
+    @Measurement(iterations = MEASUREMENT_ITERATIONS, timeUnit = TimeUnit.MILLISECONDS)
     public void write10KSingleNodeWithTenInnerItemsInCommitPerWriteBenchmark() throws Exception {
         final DataTreeSnapshot snapshot = datastore.takeSnapshot();
         for (int outerListKey = 0; outerListKey < OUTER_LIST_10K; ++outerListKey) {
diff --git a/pom.xml b/pom.xml
index ab46986476808eb7474c9a677e40a9e7f5b91d24..a0e081e02b2165653c26a3288670ee2e6f552229 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <module>restconf</module>
         <module>websocket</module>
         <module>yang</module>
-        <module>benchmarks</module>
       <!-- module>third-party</module -->
     </modules>
 
+    <profiles>
+      <profile>
+        <id>benchmarks</id>
+        <activation>
+          <activeByDefault>false</activeByDefault>
+        </activation>
+        <modules>
+          <module>benchmarks</module>
+        </modules>
+      </profile>
+    </profiles>
+
     <build>
         <pluginManagement>        
             <plugins>