You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/06/10 07:06:43 UTC

[1/2] camel git commit: Polished

Repository: camel
Updated Branches:
  refs/heads/master 40a5d7e04 -> 46bf84321


Polished


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8cdd4901
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8cdd4901
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8cdd4901

Branch: refs/heads/master
Commit: 8cdd490186002c6961c5507f4437d82c3de47d67
Parents: 40a5d7e
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Jun 10 07:56:00 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Jun 10 07:56:20 2017 +0200

----------------------------------------------------------------------
 .../org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java    | 4 +---
 .../test/java/org/apache/camel/itest/jmh/TypeConverterTest.java | 5 +----
 2 files changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8cdd4901/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java
index d049978..eebbc07 100644
--- a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java
@@ -59,8 +59,6 @@ public class DefaultUuidGeneratorTest {
             .forks(1)
             .shouldFailOnError(true)
             .shouldDoGC(true)
-            //.jvmArgs("-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining")
-            //.addProfiler(WinPerfAsmProfiler.class)
             .build();
 
         new Runner(opt).run();
@@ -81,7 +79,7 @@ public class DefaultUuidGeneratorTest {
     @Benchmark
     @BenchmarkMode(Mode.AverageTime)
     @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @Measurement(batchSize = 1000)
+    @Measurement(batchSize = 1000000)
     public void benchmark(BenchmarkState state, Blackhole bh) {
         String id = state.uuid.generateUuid();
         bh.consume(id);

http://git-wip-us.apache.org/repos/asf/camel/blob/8cdd4901/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java
index c837dfd..48a28aa 100644
--- a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java
@@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.impl.DefaultUuidGenerator;
 import org.junit.Test;
 import org.openjdk.jmh.annotations.Benchmark;
 import org.openjdk.jmh.annotations.BenchmarkMode;
@@ -60,8 +59,6 @@ public class TypeConverterTest {
             .forks(1)
             .shouldFailOnError(true)
             .shouldDoGC(true)
-            //.jvmArgs("-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintInlining")
-            //.addProfiler(WinPerfAsmProfiler.class)
             .build();
 
         new Runner(opt).run();
@@ -97,7 +94,7 @@ public class TypeConverterTest {
     @Benchmark
     @BenchmarkMode(Mode.AverageTime)
     @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @Measurement(batchSize = 1000)
+    @Measurement(batchSize = 1000000)
     public void typeConvertIntegerToString(BenchmarkState state, Blackhole bh) {
         String id = state.camel.getTypeConverter().convertTo(String.class, 12345);
         bh.consume(id);


[2/2] camel git commit: Add camel-jmh tests

Posted by da...@apache.org.
Add camel-jmh tests


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/46bf8432
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/46bf8432
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/46bf8432

Branch: refs/heads/master
Commit: 46bf8432192c46851b11cb464f2938b613607a8e
Parents: 8cdd490
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Jun 10 08:02:27 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Jun 10 09:06:36 2017 +0200

----------------------------------------------------------------------
 tests/camel-jmh/pom.xml                         |   5 +
 .../camel/itest/jmh/CaseInsensitiveMapTest.java | 144 +++++++++++++++++++
 2 files changed, 149 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/46bf8432/tests/camel-jmh/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-jmh/pom.xml b/tests/camel-jmh/pom.xml
index ba4d11d..de625ea 100644
--- a/tests/camel-jmh/pom.xml
+++ b/tests/camel-jmh/pom.xml
@@ -51,6 +51,11 @@
       <artifactId>camel-core</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-headersmap</artifactId>
+      <scope>test</scope>
+    </dependency>
 
     <dependency>
       <groupId>junit</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/46bf8432/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CaseInsensitiveMapTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CaseInsensitiveMapTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CaseInsensitiveMapTest.java
new file mode 100644
index 0000000..f1a0a21
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CaseInsensitiveMapTest.java
@@ -0,0 +1,144 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest.jmh;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.junit.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.infra.Blackhole;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+import org.openjdk.jmh.runner.options.TimeValue;
+
+/**
+ * Tests {@link CaseInsensitiveMap}
+ */
+public class CaseInsensitiveMapTest {
+
+    @Test
+    public void launchBenchmark() throws Exception {
+        Options opt = new OptionsBuilder()
+            // Specify which benchmarks to run.
+            // You can be more specific if you'd like to run only one benchmark per test.
+            .include(this.getClass().getName() + ".*")
+            // Set the following options as needed
+            .mode(Mode.AverageTime)
+            .timeUnit(TimeUnit.MICROSECONDS)
+            .warmupTime(TimeValue.seconds(1))
+            .warmupIterations(2)
+            .measurementTime(TimeValue.seconds(1))
+            .measurementIterations(2)
+            .threads(2)
+            .forks(1)
+            .shouldFailOnError(true)
+            .shouldDoGC(true)
+            .build();
+
+        new Runner(opt).run();
+    }
+
+    // The JMH samples are the best documentation for how to use it
+    // http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
+    @State(Scope.Thread)
+    public static class BenchmarkState {
+        CaseInsensitiveMap camelMap;
+        com.cedarsoftware.util.CaseInsensitiveMap cedarsoftMap;
+        HashMap hashMap;
+
+        @Setup(Level.Trial)
+        public void initialize() {
+            camelMap = new CaseInsensitiveMap();
+            cedarsoftMap = new com.cedarsoftware.util.CaseInsensitiveMap();
+            hashMap = new HashMap();
+        }
+
+    }
+
+    @Benchmark
+    @BenchmarkMode(Mode.AverageTime)
+    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @Measurement(batchSize = 1000000)
+    public void camelMap(BenchmarkState state, Blackhole bh) {
+        Map map = state.camelMap;
+
+        map.put("foo", "Hello World");
+        Object o1 = map.get("foo");
+        bh.consume(o1);
+        Object o2 = map.get("FOO");
+        bh.consume(o2);
+
+        map.put("BAR", "Bye World");
+        Object o3 = map.get("bar");
+        bh.consume(o3);
+        Object o4 = map.get("BAR");
+        bh.consume(o4);
+    }
+
+    @Benchmark
+    @BenchmarkMode(Mode.AverageTime)
+    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @Measurement(batchSize = 1000000)
+    public void cedarsoftMap(BenchmarkState state, Blackhole bh) {
+        Map map = state.cedarsoftMap;
+
+        map.put("foo", "Hello World");
+        Object o1 = map.get("foo");
+        bh.consume(o1);
+        Object o2 = map.get("FOO");
+        bh.consume(o2);
+
+        map.put("BAR", "Bye World");
+        Object o3 = map.get("bar");
+        bh.consume(o3);
+        Object o4 = map.get("BAR");
+        bh.consume(o4);
+    }
+
+    @Benchmark
+    @BenchmarkMode(Mode.AverageTime)
+    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @Measurement(batchSize = 1000000)
+    public void hashMap(BenchmarkState state, Blackhole bh) {
+        Map map = state.hashMap;
+
+        map.put("foo", "Hello World");
+        Object o1 = map.get("foo");
+        bh.consume(o1);
+        Object o2 = map.get("FOO");
+        bh.consume(o2);
+
+        map.put("BAR", "Bye World");
+        Object o3 = map.get("bar");
+        bh.consume(o3);
+        Object o4 = map.get("BAR");
+        bh.consume(o4);
+    }
+
+}