You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by df...@apache.org on 2021/04/20 18:31:36 UTC
[camel-performance-tests] 08/16: CAMEL-16251 - Move Performance and
jmh itests in a separated repository
This is an automated email from the ASF dual-hosted git repository.
dfoulks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-performance-tests.git
commit 42b1442cbafbf5eb064f2505a1b006fcc4d19764
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 10 15:58:43 2021 +0100
CAMEL-16251 - Move Performance and jmh itests in a separated repository
---
pom.xml | 1 +
tests/camel-jmh/pom.xml | 142 ++++++++++++++
.../camel/itest/jmh/CSimpleOperatorTest.java | 131 +++++++++++++
.../org/apache/camel/itest/jmh/CSimpleScript1.java | 47 +++++
.../org/apache/camel/itest/jmh/CSimpleScript2.java | 47 +++++
.../org/apache/camel/itest/jmh/CSimpleScript3.java | 47 +++++
.../camel/itest/jmh/CaseInsensitiveMapTest.java | 212 +++++++++++++++++++++
.../camel/itest/jmh/ContainsIgnoreCaseTest.java | 85 +++++++++
.../camel/itest/jmh/DefaultUuidGeneratorTest.java | 84 ++++++++
.../camel/itest/jmh/DirectConcurrentTest.java | 120 ++++++++++++
.../camel/itest/jmh/FastTypeConverterTest.java | 108 +++++++++++
.../java/org/apache/camel/itest/jmh/JoorTest.java | 154 +++++++++++++++
.../camel/itest/jmh/LoadTypeConvertersTest.java | 124 ++++++++++++
.../apache/camel/itest/jmh/LogEndpointTest.java | 102 ++++++++++
.../apache/camel/itest/jmh/NormalizeUriTest.java | 139 ++++++++++++++
.../camel/itest/jmh/SimpleExpressionTest.java | 112 +++++++++++
.../camel/itest/jmh/SimpleMockPlaceholderTest.java | 117 ++++++++++++
.../org/apache/camel/itest/jmh/SimpleMockTest.java | 110 +++++++++++
.../apache/camel/itest/jmh/SimpleOperatorTest.java | 131 +++++++++++++
.../camel/itest/jmh/SlowTypeConverterTest.java | 106 +++++++++++
.../apache/camel/itest/jmh/TypeConverterTest.java | 175 +++++++++++++++++
.../src/test/resources/META-INF/LICENSE.txt | 203 ++++++++++++++++++++
.../src/test/resources/META-INF/NOTICE.txt | 11 ++
.../services/org/apache/camel/csimple.properties | 20 ++
.../camel-jmh/src/test/resources/log4j2.properties | 28 +++
tests/camel-jmh/src/test/resources/sample_soap.xml | 33 ++++
tests/pom.xml | 41 ++++
27 files changed, 2630 insertions(+)
diff --git a/pom.xml b/pom.xml
index 8bc7869..d74f995 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,6 +78,7 @@
</distributionManagement>
<modules>
+ <module>tests</module>
<module>profiling</module>
</modules>
diff --git a/tests/camel-jmh/pom.xml b/tests/camel-jmh/pom.xml
new file mode 100644
index 0000000..bf88a71
--- /dev/null
+++ b/tests/camel-jmh/pom.xml
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel.tests</groupId>
+ <artifactId>tests</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-jmh</artifactId>
+ <name>Camel :: Integration Tests :: JMH</name>
+ <description>Performs JMH performance tests</description>
+
+ <dependencyManagement>
+ <dependencies>
+ <!-- Add Camel BOM -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-bom</artifactId>
+ <version>${camel.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.openjdk.jmh</groupId>
+ <artifactId>jmh-core</artifactId>
+ <version>${jmh-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.openjdk.jmh</groupId>
+ <artifactId>jmh-generator-annprocess</artifactId>
+ <version>${jmh-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-headersmap</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-netty</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-joor</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ <version>${junit-jupiter-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>${commons-lang3-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <scope>test</scope>
+ <version>${log4j2-version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${maven-surefire-plugin-version}</version>
+ <configuration>
+ <includes>
+ <include>**/*XXX.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <!-- to run tests: mvn test -P jmh -->
+ <profiles>
+ <profile>
+ <id>jmh</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${maven-surefire-plugin-version}</version>
+ <configuration>
+ <forkedProcessTimeoutInSeconds>1800</forkedProcessTimeoutInSeconds>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleOperatorTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleOperatorTest.java
new file mode 100644
index 0000000..3336052
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleOperatorTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.Language;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests a Compiled Compile Simple operator expression
+ */
+public class CSimpleOperatorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(CSimpleOperatorTest.class);
+
+ @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.All)
+ .timeUnit(TimeUnit.MICROSECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(10))
+ .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 {
+ CamelContext camel;
+ String expression = "${header.gold} == 123";
+ String expression2 = "${header.gold} > 123";
+ String expression3 = "${header.gold} < 123";
+ Exchange exchange;
+ Language csimple;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+ try {
+ camel.getTypeConverterRegistry().getStatistics().setStatisticsEnabled(true);
+ camel.start();
+ exchange = new DefaultExchange(camel);
+ exchange.getIn().setBody("World");
+ exchange.getIn().setHeader("gold", "123");
+ csimple = camel.resolveLanguage("csimple");
+
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ LOG.info("" + camel.getTypeConverterRegistry().getStatistics());
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void csimplePredicate(BenchmarkState state, Blackhole bh) {
+ boolean out = state.csimple.createPredicate(state.expression).matches(state.exchange);
+ if (!out) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out);
+ boolean out2 = state.csimple.createPredicate(state.expression2).matches(state.exchange);
+ if (out2) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out2);
+ boolean out3 = state.csimple.createPredicate(state.expression3).matches(state.exchange);
+ if (out3) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out3);
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript1.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript1.java
new file mode 100644
index 0000000..a94d7d5
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript1.java
@@ -0,0 +1,47 @@
+/*
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.language.csimple.CSimpleSupport;
+
+import static org.apache.camel.language.csimple.CSimpleHelper.headerAs;
+
+public class CSimpleScript1 extends CSimpleSupport {
+
+ public CSimpleScript1() {
+ }
+
+ @Override
+ public String getText() {
+ return "${header.gold} == 123";
+ }
+
+ @Override
+ public Object evaluate(CamelContext context, Exchange exchange, Message message, Object body)
+ throws Exception {
+ return headerAs(message, "gold", int.class) == 123;
+ }
+
+ @Override
+ public boolean isPredicate() {
+ return true;
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript2.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript2.java
new file mode 100644
index 0000000..b5f8312
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript2.java
@@ -0,0 +1,47 @@
+/*
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.language.csimple.CSimpleSupport;
+
+import static org.apache.camel.language.csimple.CSimpleHelper.headerAs;
+
+public class CSimpleScript2 extends CSimpleSupport {
+
+ public CSimpleScript2() {
+ }
+
+ @Override
+ public String getText() {
+ return "${header.gold} > 123";
+ }
+
+ @Override
+ public Object evaluate(CamelContext context, Exchange exchange, Message message, Object body)
+ throws Exception {
+ return headerAs(message, "gold", int.class) > 123;
+ }
+
+ @Override
+ public boolean isPredicate() {
+ return true;
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript3.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript3.java
new file mode 100644
index 0000000..64c6ec5
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CSimpleScript3.java
@@ -0,0 +1,47 @@
+/*
+ * 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 org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.language.csimple.CSimpleSupport;
+
+import static org.apache.camel.language.csimple.CSimpleHelper.headerAs;
+
+public class CSimpleScript3 extends CSimpleSupport {
+
+ public CSimpleScript3() {
+ }
+
+ @Override
+ public String getText() {
+ return "${header.gold} < 123";
+ }
+
+ @Override
+ public Object evaluate(CamelContext context, Exchange exchange, Message message, Object body)
+ throws Exception {
+ return headerAs(message, "gold", int.class) < 123;
+ }
+
+ @Override
+ public boolean isPredicate() {
+ return true;
+ }
+
+}
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..42c4fde
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/CaseInsensitiveMapTest.java
@@ -0,0 +1,212 @@
+/*
+ * 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 java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+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;
+
+import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
+
+/**
+ * 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.SampleTime)
+ .timeUnit(TimeUnit.MILLISECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(5))
+ .measurementIterations(5)
+ .threads(1)
+ .forks(1)
+ .shouldFailOnError(true)
+ .shouldDoGC(true)
+ .measurementBatchSize(1000000)
+ .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 MapsBenchmarkState {
+ 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();
+ }
+
+ }
+
+ @State(Scope.Benchmark)
+ public static class MapsSourceDataBenchmarkState {
+ Map<String, Object> map1 = generateRandomMap(10);
+ Map<String, Object> map2 = generateRandomMap(10);
+
+ private Map<String, Object> generateRandomMap(int size) {
+ return IntStream.range(0, size)
+ .boxed()
+ .collect(Collectors.toMap(i -> randomAlphabetic(10), i -> randomAlphabetic(10)));
+ }
+ }
+
+ @Benchmark
+ public void camelMapSimpleCase(MapsBenchmarkState 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
+ public void cedarsoftMapSimpleCase(MapsBenchmarkState 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
+ public void hashMapSimpleCase(MapsBenchmarkState 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);
+ }
+
+ @Benchmark
+ public void camelMapComplexCase(
+ MapsBenchmarkState mapsBenchmarkState, MapsSourceDataBenchmarkState sourceDataState, Blackhole blackhole) {
+ // step 1 - initialize map with existing elements
+ Map map = mapsBenchmarkState.camelMap;
+
+ // step 2 - add elements one by one
+ sourceDataState.map2.entrySet().forEach(entry -> blackhole.consume(map.put(entry.getKey(), entry.getValue())));
+
+ // step 3 - remove elements one by one
+ sourceDataState.map1.keySet().forEach(key -> blackhole.consume(map.get(key)));
+
+ // step 4 - remove elements one by one
+ sourceDataState.map1.keySet().forEach(key -> blackhole.consume(map.remove(key)));
+
+ // step 5 - add couple of element at once
+ map.putAll(sourceDataState.map1);
+
+ blackhole.consume(map);
+ }
+
+ @Benchmark
+ public void cedarsoftMapComplexCase(
+ MapsBenchmarkState mapsBenchmarkState, MapsSourceDataBenchmarkState sourceDataState, Blackhole blackhole) {
+ // step 1 - initialize map with existing elements
+ Map map = mapsBenchmarkState.cedarsoftMap;
+
+ // step 2 - add elements one by one
+ sourceDataState.map2.entrySet().forEach(entry -> blackhole.consume(map.put(entry.getKey(), entry.getValue())));
+
+ // step 3 - remove elements one by one
+ sourceDataState.map1.keySet().forEach(key -> blackhole.consume(map.get(key)));
+
+ // step 4 - remove elements one by one
+ sourceDataState.map1.keySet().forEach(key -> blackhole.consume(map.remove(key)));
+
+ // step 5 - add couple of element at once
+ map.putAll(sourceDataState.map1);
+
+ blackhole.consume(map);
+ }
+
+ @Benchmark
+ public void hashMapComplexCase(
+ MapsBenchmarkState mapsBenchmarkState, MapsSourceDataBenchmarkState sourceDataState, Blackhole blackhole) {
+ // step 1 - initialize map with existing elements
+ Map map = mapsBenchmarkState.hashMap;
+
+ // step 2 - add elements one by one
+ sourceDataState.map2.entrySet().forEach(entry -> blackhole.consume(map.put(entry.getKey(), entry.getValue())));
+
+ // step 3 - remove elements one by one
+ sourceDataState.map1.keySet().forEach(key -> blackhole.consume(map.get(key)));
+
+ // step 4 - remove elements one by one
+ sourceDataState.map1.keySet().forEach(key -> blackhole.consume(map.remove(key)));
+
+ // step 5 - add couple of element at once
+ map.putAll(sourceDataState.map1);
+
+ blackhole.consume(map);
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/ContainsIgnoreCaseTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/ContainsIgnoreCaseTest.java
new file mode 100644
index 0000000..e8849cc
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/ContainsIgnoreCaseTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.util.StringHelper;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+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 the {@link StringHelper}.
+ * <p/>
+ * Thanks to this SO answer: https://stackoverflow.com/questions/30485856/how-to-run-jmh-from-inside-junit-tests
+ */
+public class ContainsIgnoreCaseTest {
+
+ @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.All)
+ .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 {
+ @Setup(Level.Trial)
+ public void initialize() {
+ }
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000000)
+ public void benchmark(BenchmarkState state, Blackhole bh) {
+ bh.consume(StringHelper.containsIgnoreCase("abc", "A"));
+ bh.consume(StringHelper.containsIgnoreCase("abc", "aB"));
+ bh.consume(StringHelper.containsIgnoreCase("abc", "aBc"));
+ bh.consume(StringHelper.containsIgnoreCase("abc", "ad"));
+ bh.consume(StringHelper.containsIgnoreCase("abc", "abD"));
+ bh.consume(StringHelper.containsIgnoreCase("abc", "ABD"));
+ }
+
+}
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
new file mode 100644
index 0000000..381d222
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.support.DefaultUuidGenerator;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+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 the {@link DefaultUuidGenerator}.
+ * <p/>
+ * Thanks to this SO answer: https://stackoverflow.com/questions/30485856/how-to-run-jmh-from-inside-junit-tests
+ */
+public class DefaultUuidGeneratorTest {
+
+ @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.All)
+ .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 {
+ DefaultUuidGenerator uuid;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ uuid = new DefaultUuidGenerator();
+ }
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000000)
+ public void benchmark(BenchmarkState state, Blackhole bh) {
+ String id = state.uuid.generateUuid();
+ bh.consume(id);
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DirectConcurrentTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DirectConcurrentTest.java
new file mode 100644
index 0000000..97c1b06
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DirectConcurrentTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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;
+
+/**
+ * Tests a simple Camel route
+ */
+public class DirectConcurrentTest {
+
+ @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.MILLISECONDS)
+ .warmupIterations(1)
+ .measurementIterations(5)
+ .threads(4)
+ .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 {
+ CamelContext camel;
+ ProducerTemplate producer;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+ try {
+ camel.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start")
+ .to("direct:a")
+ .to("direct:b")
+ .to("direct:c")
+ .to("mock:result?retainFirst=0");
+
+ from("direct:a")
+ .to("log:a?level=OFF");
+
+ from("direct:b")
+ .to("log:b?level=OFF");
+
+ from("direct:c")
+ .to("log:c?level=OFF");
+ }
+ });
+ camel.start();
+ producer = camel.createProducerTemplate();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ producer.stop();
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ }
+
+ @Benchmark
+ public void directConcurrentTest(BenchmarkState state, Blackhole bh) {
+ ProducerTemplate template = state.producer;
+ for (int i = 0; i < 50000; i++) {
+ template.sendBody("direct:start", "Hello " + i);
+ }
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/FastTypeConverterTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/FastTypeConverterTest.java
new file mode 100644
index 0000000..ff0ca6d
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/FastTypeConverterTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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 the fast {@link org.apache.camel.TypeConverter} which uses the code generated loader
+ */
+public class FastTypeConverterTest {
+
+ @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.SampleTime)
+ .timeUnit(TimeUnit.MILLISECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(5))
+ .measurementIterations(3)
+ .threads(1)
+ .forks(1)
+ .shouldFailOnError(true)
+ .shouldDoGC(true)
+ .measurementBatchSize(100000)
+ .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 BenchmarkCamelContextState {
+ ByteBuf buffer;
+ byte[] bytes = "Hello World this is some text".getBytes();
+
+ CamelContext camel;
+
+ @Setup(Level.Trial)
+ public void initialize() throws IOException {
+ camel = new DefaultCamelContext();
+ try {
+ // dont scan for additional type converters
+ camel.setLoadTypeConverters(false);
+ camel.start();
+ } catch (Exception e) {
+ // ignore
+ }
+
+ buffer = ByteBufAllocator.DEFAULT.buffer(bytes.length);
+ buffer.writeBytes(bytes);
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ @Benchmark
+ public void typeConvertByteBufToArray(BenchmarkCamelContextState state, Blackhole bh) {
+ byte[] arr = state.camel.getTypeConverter().convertTo(byte[].class, state.buffer);
+ bh.consume(arr);
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/JoorTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/JoorTest.java
new file mode 100644
index 0000000..d0f78b0
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/JoorTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.Language;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JoorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(JoorTest.class);
+
+ @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.All)
+ .timeUnit(TimeUnit.MICROSECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(10))
+ .measurementIterations(2)
+ .threads(2)
+ .forks(1)
+ .shouldFailOnError(true)
+ .shouldDoGC(true)
+ .build();
+
+ new Runner(opt).run();
+ }
+
+ public static class MyUser {
+
+ private int age = 44;
+ private String name = "tony";
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ // 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 {
+ CamelContext camel;
+ Exchange exchange;
+ String joorCode
+ = "var user = message.getBody(org.apache.camel.itest.jmh.JoorTest.MyUser.class); return user.getName() != null && user.getAge() > 20;";
+ String simpleCode = "${body.name} != null && ${body.age} > 20";
+ Predicate joorPredicate;
+ Predicate simplePredicate;
+ Language joor;
+ Language simple;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+ try {
+ camel.start();
+ exchange = new DefaultExchange(camel);
+ exchange.getIn().setBody(new MyUser());
+ exchange.getIn().setHeader("gold", "123");
+ joor = camel.resolveLanguage("joor");
+ joorPredicate = joor.createPredicate(joorCode);
+ simple = camel.resolveLanguage("simple");
+ simplePredicate = simple.createPredicate(simpleCode);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void joorPredicate(BenchmarkState state, Blackhole bh) {
+ boolean out = state.joorPredicate.matches(state.exchange);
+ if (!out) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out);
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void simplePredicate(BenchmarkState state, Blackhole bh) {
+ boolean out = state.simplePredicate.matches(state.exchange);
+ if (!out) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out);
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/LoadTypeConvertersTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/LoadTypeConvertersTest.java
new file mode 100644
index 0000000..6bd6504
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/LoadTypeConvertersTest.java
@@ -0,0 +1,124 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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 loading type converters from classpath scanning.
+ */
+public class LoadTypeConvertersTest {
+
+ @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.All)
+ .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();
+ }
+
+ /**
+ * Setup a fresh CamelContext per invocation
+ */
+ @State(Scope.Thread)
+ public static class BenchmarkState {
+ CamelContext camel;
+
+ @Setup(Level.Invocation)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+ }
+
+ @TearDown(Level.Invocation)
+ public void close() {
+ try {
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void load(BenchmarkState state, Blackhole bh) {
+ int size = 0;
+ try {
+ state.camel.start();
+
+ size = state.camel.getTypeConverterRegistry().size();
+ bh.consume(size);
+ } catch (Exception e) {
+ // ignore
+ }
+
+ if (size < 200) {
+ throw new IllegalArgumentException("Should have 200+ type converters loaded");
+ }
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void notLoad(BenchmarkState state, Blackhole bh) {
+ int size = 0;
+ try {
+ state.camel.setLoadTypeConverters(false);
+ state.camel.start();
+
+ size = state.camel.getTypeConverterRegistry().size();
+ bh.consume(size);
+ } catch (Exception e) {
+ // ignore
+ }
+
+ if (size > 200) {
+ throw new IllegalArgumentException("Should not load additional type converters from classpath");
+ }
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/LogEndpointTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/LogEndpointTest.java
new file mode 100644
index 0000000..c80f9a3
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/LogEndpointTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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 fast property binding on endpoints
+ */
+public class LogEndpointTest {
+
+ @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.All)
+ .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 {
+ CamelContext camel;
+ AtomicInteger counter;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+ camel.getGlobalOptions().put(Exchange.MAXIMUM_ENDPOINT_CACHE_SIZE, "1");
+ counter = new AtomicInteger();
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void logEndpoint(BenchmarkState state, Blackhole bh) {
+ // use the legacy binding which uses reflection
+ // Endpoint out = state.camel.getEndpoint("log:foo?basicPropertyBinding=true&showAll=true&groupSize=" + state.counter.incrementAndGet());
+ Endpoint out = state.camel.getEndpoint("log:foo?showAll=true&groupSize=" + state.counter.incrementAndGet());
+ bh.consume(out);
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/NormalizeUriTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/NormalizeUriTest.java
new file mode 100644
index 0000000..610b763
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/NormalizeUriTest.java
@@ -0,0 +1,139 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.util.URISupport;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+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 the {@link org.apache.camel.util.URISupport#normalizeUri(String)}.
+ * <p/>
+ * Thanks to this SO answer: https://stackoverflow.com/questions/30485856/how-to-run-jmh-from-inside-junit-tests
+ */
+public class NormalizeUriTest {
+
+ @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.All)
+ .timeUnit(TimeUnit.MICROSECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(1))
+ .measurementIterations(2)
+ .threads(2)
+ .forks(1)
+ .shouldFailOnError(true)
+ .shouldDoGC(false)
+ .measurementBatchSize(100000)
+ .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 {
+ @Setup(Level.Trial)
+ public void initialize() {
+ }
+ }
+
+ @Benchmark
+ public void benchmarkMixed(ContainsIgnoreCaseTest.BenchmarkState state, Blackhole bh) throws Exception {
+ // fast
+ bh.consume(URISupport.normalizeUri("log:foo?level=INFO&logMask=false&exchangeFormatter=#myFormatter"));
+ // slow
+ bh.consume(URISupport.normalizeUri("http://www.google.com?q=S%C3%B8ren%20Hansen"));
+ // fast
+ bh.consume(URISupport.normalizeUri("file:target/inbox?recursive=true"));
+ // slow
+ bh.consume(URISupport.normalizeUri("http://www.google.com?q=S%C3%B8ren%20Hansen"));
+ // fast
+ bh.consume(URISupport.normalizeUri("seda:foo?concurrentConsumer=2"));
+ // slow
+ bh.consume(URISupport.normalizeUri("ftp://us%40r:t%25st@localhost:21000/tmp3/camel?foo=us@r"));
+ // fast
+ bh.consume(URISupport.normalizeUri("http:www.google.com?q=Camel"));
+ // slow
+ bh.consume(URISupport.normalizeUri("ftp://us@r:t%25st@localhost:21000/tmp3/camel?foo=us@r"));
+ }
+
+ @Benchmark
+ public void benchmarkFast(ContainsIgnoreCaseTest.BenchmarkState state, Blackhole bh) throws Exception {
+ bh.consume(URISupport.normalizeUri("log:foo"));
+ bh.consume(URISupport.normalizeUri("log:foo?level=INFO&logMask=false&exchangeFormatter=#myFormatter"));
+ bh.consume(URISupport.normalizeUri("file:target/inbox?recursive=true"));
+ bh.consume(URISupport.normalizeUri("smtp://localhost?password=secret&username=davsclaus"));
+ bh.consume(URISupport.normalizeUri("seda:foo?concurrentConsumer=2"));
+ bh.consume(URISupport.normalizeUri("irc:someserver/#camel?user=davsclaus"));
+ bh.consume(URISupport.normalizeUri("http:www.google.com?q=Camel"));
+ bh.consume(URISupport.normalizeUri("smtp://localhost?to=foo&to=bar&from=me&from=you"));
+ }
+
+ @Benchmark
+ public void benchmarkFastSorted(ContainsIgnoreCaseTest.BenchmarkState state, Blackhole bh) throws Exception {
+ bh.consume(URISupport.normalizeUri("log:foo"));
+ bh.consume(URISupport.normalizeUri("log:foo?exchangeFormatter=#myFormatter&level=INFO&logMask=false"));
+ bh.consume(URISupport.normalizeUri("file:target/inbox?recursive=true"));
+ bh.consume(URISupport.normalizeUri("smtp://localhost?username=davsclaus&password=secret"));
+ bh.consume(URISupport.normalizeUri("seda:foo?concurrentConsumer=2"));
+ bh.consume(URISupport.normalizeUri("irc:someserver/#camel?user=davsclaus"));
+ bh.consume(URISupport.normalizeUri("http:www.google.com?q=Camel"));
+ bh.consume(URISupport.normalizeUri("smtp://localhost?&from=me&from=you&to=foo&to=bar"));
+ }
+
+ @Benchmark
+ public void benchmarkSlow(ContainsIgnoreCaseTest.BenchmarkState state, Blackhole bh) throws Exception {
+ bh.consume(URISupport.normalizeUri("http://www.google.com?q=S%C3%B8ren%20Hansen"));
+ bh.consume(URISupport.normalizeUri("ftp://us%40r:t%st@localhost:21000/tmp3/camel?foo=us@r"));
+ bh.consume(URISupport.normalizeUri("ftp://us%40r:t%25st@localhost:21000/tmp3/camel?foo=us@r"));
+ bh.consume(URISupport.normalizeUri("ftp://us@r:t%st@localhost:21000/tmp3/camel?foo=us@r"));
+ bh.consume(URISupport.normalizeUri("ftp://us@r:t%25st@localhost:21000/tmp3/camel?foo=us@r"));
+ bh.consume(URISupport
+ .normalizeUri("xmpp://camel-user@localhost:123/test-user@localhost?password=secret&serviceName=someCoolChat"));
+ bh.consume(URISupport.normalizeUri(
+ "xmpp://camel-user@localhost:123/test-user@localhost?password=RAW(++?w0rd)&serviceName=some chat"));
+ bh.consume(URISupport.normalizeUri(
+ "xmpp://camel-user@localhost:123/test-user@localhost?password=RAW(foo %% bar)&serviceName=some chat"));
+ }
+
+ @Benchmark
+ public void sorting(ContainsIgnoreCaseTest.BenchmarkState state, Blackhole bh) throws Exception {
+ bh.consume(URISupport
+ .normalizeUri("log:foo?zzz=123&xxx=222&hhh=444&aaa=tru&d=yes&cc=no&Camel=awesome&foo.hey=bar&foo.bar=blah"));
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleExpressionTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleExpressionTest.java
new file mode 100644
index 0000000..c44781d
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleExpressionTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.Language;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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 a Simple expression
+ */
+public class SimpleExpressionTest {
+
+ @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.All)
+ .timeUnit(TimeUnit.MICROSECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(10))
+ .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 {
+ CamelContext camel;
+ String expression = "Hello ${body}";
+ Exchange exchange;
+ Language simple;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+ try {
+ camel.start();
+ exchange = new DefaultExchange(camel);
+ exchange.getIn().setBody("World");
+ simple = camel.resolveLanguage("simple");
+
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void simpleExpression(BenchmarkState state, Blackhole bh) {
+ String out = state.simple.createExpression(state.expression).evaluate(state.exchange, String.class);
+ if (!out.equals("Hello World")) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out);
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleMockPlaceholderTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleMockPlaceholderTest.java
new file mode 100644
index 0000000..bf5e624
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleMockPlaceholderTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.Properties;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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 a simple Camel route
+ */
+public class SimpleMockPlaceholderTest {
+
+ @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.All)
+ .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 {
+ CamelContext camel;
+ ProducerTemplate producer;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+
+ Properties prop = new Properties();
+ prop.put("foolish", "log:foo?groupSize=10");
+ prop.put("mymock", "mock:result?retainFirst=0");
+ camel.getPropertiesComponent().setInitialProperties(prop);
+
+ try {
+ camel.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").to("{{foolish}}").to("log:bar").to("{{mymock}}");
+ }
+ });
+ camel.start();
+ producer = camel.createProducerTemplate();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ producer.stop();
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void simpleMockPlaceholderTest(BenchmarkState state, Blackhole bh) {
+ ProducerTemplate template = state.producer;
+ template.sendBody("direct:start", "Hello World");
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleMockTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleMockTest.java
new file mode 100644
index 0000000..dcae207
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleMockTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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 a simple Camel route
+ */
+public class SimpleMockTest {
+
+ @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.All)
+ .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 {
+ CamelContext camel;
+ ProducerTemplate producer;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+ try {
+ camel.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:start").to("log:foo").to("log:bar").to("mock:result?retainFirst=0");
+ }
+ });
+ camel.start();
+ producer = camel.createProducerTemplate();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ producer.stop();
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void simpleMockTest(BenchmarkState state, Blackhole bh) {
+ ProducerTemplate template = state.producer;
+ template.sendBody("direct:start", "Hello World");
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleOperatorTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleOperatorTest.java
new file mode 100644
index 0000000..fc00074
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SimpleOperatorTest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.spi.Language;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Tests a Simple operator expression
+ */
+public class SimpleOperatorTest {
+
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleOperatorTest.class);
+
+ @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.All)
+ .timeUnit(TimeUnit.MICROSECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(10))
+ .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 {
+ CamelContext camel;
+ String expression = "${header.gold} == 123";
+ String expression2 = "${header.gold} > 123";
+ String expression3 = "${header.gold} < 123";
+ Exchange exchange;
+ Language simple;
+
+ @Setup(Level.Trial)
+ public void initialize() {
+ camel = new DefaultCamelContext();
+ try {
+ camel.getTypeConverterRegistry().getStatistics().setStatisticsEnabled(true);
+ camel.start();
+ exchange = new DefaultExchange(camel);
+ exchange.getIn().setBody("World");
+ exchange.getIn().setHeader("gold", "123");
+ simple = camel.resolveLanguage("simple");
+
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ LOG.info("" + camel.getTypeConverterRegistry().getStatistics());
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+
+ }
+
+ @Benchmark
+ @Measurement(batchSize = 1000)
+ public void simplePredicate(BenchmarkState state, Blackhole bh) {
+ boolean out = state.simple.createPredicate(state.expression).matches(state.exchange);
+ if (!out) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out);
+ boolean out2 = state.simple.createPredicate(state.expression2).matches(state.exchange);
+ if (out2) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out2);
+ boolean out3 = state.simple.createPredicate(state.expression3).matches(state.exchange);
+ if (out3) {
+ throw new IllegalArgumentException("Evaluation failed");
+ }
+ bh.consume(out3);
+ }
+
+}
diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SlowTypeConverterTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SlowTypeConverterTest.java
new file mode 100644
index 0000000..a044263
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/SlowTypeConverterTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufAllocator;
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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 the default slow {@link org.apache.camel.TypeConverter} which uses method call reflection
+ */
+public class SlowTypeConverterTest {
+
+ @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.SampleTime)
+ .timeUnit(TimeUnit.MILLISECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(5))
+ .measurementIterations(3)
+ .threads(1)
+ .forks(1)
+ .shouldFailOnError(true)
+ .shouldDoGC(true)
+ .measurementBatchSize(100000)
+ .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 BenchmarkCamelContextState {
+ ByteBuf buffer;
+ byte[] bytes = "Hello World this is some text".getBytes();
+
+ CamelContext camel;
+
+ @Setup(Level.Trial)
+ public void initialize() throws IOException {
+ camel = new DefaultCamelContext();
+ try {
+ camel.start();
+ } catch (Exception e) {
+ // ignore
+ }
+
+ buffer = ByteBufAllocator.DEFAULT.buffer(bytes.length);
+ buffer.writeBytes(bytes);
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ @Benchmark
+ public void typeConvertByteBufToArray(BenchmarkCamelContextState state, Blackhole bh) {
+ byte[] arr = state.camel.getTypeConverter().convertTo(byte[].class, state.buffer);
+ bh.consume(arr);
+ }
+
+}
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
new file mode 100644
index 0000000..35a5101
--- /dev/null
+++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java
@@ -0,0 +1,175 @@
+/*
+ * 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.io.ByteArrayInputStream;
+import java.io.CharArrayReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeUnit;
+
+import org.w3c.dom.Document;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.LoggingLevel;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.util.IOHelper;
+import org.junit.jupiter.api.Test;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.Level;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.annotations.TearDown;
+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 org.apache.camel.TypeConverter}
+ */
+public class TypeConverterTest {
+
+ @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.Throughput)
+ .timeUnit(TimeUnit.MILLISECONDS)
+ .warmupTime(TimeValue.seconds(1))
+ .warmupIterations(2)
+ .measurementTime(TimeValue.seconds(5))
+ .measurementIterations(3)
+ .threads(1)
+ .forks(1)
+ .shouldFailOnError(true)
+ .shouldDoGC(true)
+ .measurementBatchSize(1000)
+ .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 BenchmarkCamelContextState {
+ Integer someInteger = 12345;
+ String someIntegerString = String.valueOf(someInteger);
+ ByteArrayInputStream bos;
+ String xmlAsString;
+ byte[] xmlAsBytes;
+ char[] xmlAsCharArray;
+
+ CamelContext camel;
+
+ @Setup(Level.Trial)
+ public void initialize() throws IOException {
+ camel = new DefaultCamelContext();
+ try {
+ camel.start();
+ } catch (Exception e) {
+ // ignore
+ }
+
+ xmlAsString = IOHelper.loadText(getClass().getClassLoader().getResourceAsStream("sample_soap.xml"));
+ xmlAsBytes = xmlAsString.getBytes(StandardCharsets.UTF_8);
+ xmlAsCharArray = xmlAsString.toCharArray();
+ bos = new ByteArrayInputStream(xmlAsBytes);
+ }
+
+ @TearDown(Level.Trial)
+ public void close() {
+ try {
+ camel.stop();
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ @Benchmark
+ public void typeConvertIntegerToString(BenchmarkCamelContextState state, Blackhole bh) {
+ String string = state.camel.getTypeConverter().convertTo(String.class, state.someInteger);
+ bh.consume(string);
+ }
+
+ @Benchmark
+ public void typeConvertStringToInteger(BenchmarkCamelContextState state, Blackhole bh) {
+ Integer integer = state.camel.getTypeConverter().convertTo(Integer.class, state.someIntegerString);
+ bh.consume(integer);
+ }
+
+ @Benchmark
+ public void typeConvertTheSameTypes(BenchmarkCamelContextState state, Blackhole bh) {
+ String string = state.camel.getTypeConverter().convertTo(String.class, state.someIntegerString);
+ bh.consume(string);
+ }
+
+ @Benchmark
+ public void typeConvertInputStreamToString(BenchmarkCamelContextState state, Blackhole bh) {
+ state.bos.reset();
+ String string = state.camel.getTypeConverter().convertTo(String.class, state.bos);
+ bh.consume(string);
+ }
+
+ @Benchmark
+ public void typeConvertStringToInputStream(BenchmarkCamelContextState state, Blackhole bh) {
+ InputStream inputStream = state.camel.getTypeConverter().convertTo(InputStream.class, state.xmlAsString);
+ bh.consume(inputStream);
+ }
+
+ @Benchmark
+ public void typeConvertStringToDocument(BenchmarkCamelContextState state, Blackhole bh) {
+ Document document = state.camel.getTypeConverter().convertTo(Document.class, state.xmlAsString);
+ bh.consume(document);
+ }
+
+ @Benchmark
+ public void typeConvertStringToByteArray(BenchmarkCamelContextState state, Blackhole bh) {
+ byte[] bytes = state.camel.getTypeConverter().convertTo(byte[].class, state.xmlAsString);
+ bh.consume(bytes);
+ }
+
+ @Benchmark
+ public void typeConvertByteArrayToString(BenchmarkCamelContextState state, Blackhole bh) {
+ String string = state.camel.getTypeConverter().convertTo(String.class, state.xmlAsBytes);
+ bh.consume(string);
+ }
+
+ @Benchmark
+ public void typeConvertStringToEnum(BenchmarkCamelContextState state, Blackhole bh) {
+ LoggingLevel level = state.camel.getTypeConverter().convertTo(LoggingLevel.class, "WARN");
+ bh.consume(level);
+ }
+
+ @Benchmark
+ public void typeConvertReaderToByteArray(BenchmarkCamelContextState state, Blackhole bh) {
+ Reader reader = new CharArrayReader(state.xmlAsCharArray);
+ byte[] arr = state.camel.getTypeConverter().convertTo(byte[].class, reader);
+ bh.consume(arr);
+ bh.consume(reader);
+ }
+}
diff --git a/tests/camel-jmh/src/test/resources/META-INF/LICENSE.txt b/tests/camel-jmh/src/test/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/tests/camel-jmh/src/test/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
diff --git a/tests/camel-jmh/src/test/resources/META-INF/NOTICE.txt b/tests/camel-jmh/src/test/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/tests/camel-jmh/src/test/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
diff --git a/tests/camel-jmh/src/test/resources/META-INF/services/org/apache/camel/csimple.properties b/tests/camel-jmh/src/test/resources/META-INF/services/org/apache/camel/csimple.properties
new file mode 100644
index 0000000..fc8d8ef
--- /dev/null
+++ b/tests/camel-jmh/src/test/resources/META-INF/services/org/apache/camel/csimple.properties
@@ -0,0 +1,20 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+org.apache.camel.itest.jmh.CSimpleScript1
+org.apache.camel.itest.jmh.CSimpleScript2
+org.apache.camel.itest.jmh.CSimpleScript3
diff --git a/tests/camel-jmh/src/test/resources/log4j2.properties b/tests/camel-jmh/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..2ae0380
--- /dev/null
+++ b/tests/camel-jmh/src/test/resources/log4j2.properties
@@ -0,0 +1,28 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-jmh-test.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.stdout.type = Console
+appender.stdout.name = stdout
+appender.stdout.layout.type = PatternLayout
+appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file
diff --git a/tests/camel-jmh/src/test/resources/sample_soap.xml b/tests/camel-jmh/src/test/resources/sample_soap.xml
new file mode 100644
index 0000000..6800482
--- /dev/null
+++ b/tests/camel-jmh/src/test/resources/sample_soap.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Header><routing xmlns="http://someuri">xadmin;server1;community#1.0##</routing></soapenv:Header>
+ <soapenv:Body>
+ <m:buyStocks xmlns:m="http://services.samples/xsd">
+ <order><symbol>IBM</symbol><buyerID>asankha</buyerID><price>140.34</price><volume>2000</volume></order>
+ <order><symbol>MSFT</symbol><buyerID>ruwan</buyerID><price>23.56</price><volume>8030</volume></order>
+ <order><symbol>SUN</symbol><buyerID>indika</buyerID><price>14.56</price><volume>500</volume></order>
+ <order><symbol>GOOG</symbol><buyerID>chathura</buyerID><price>60.24</price><volume>40000</volume></order>
+ <order><symbol>IBM</symbol><buyerID>asankha</buyerID><price>140.34</price><volume>2000</volume></order>
+ <order><symbol>MSFT</symbol><buyerID>ruwan</buyerID><price>23.56</price><volume>803000</volume></order>
+ <order><symbol>SUN</symbol><buyerID>indika</buyerID><price>14.56</price><volume>5000</volume></order>
+ </m:buyStocks>
+ </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file
diff --git a/tests/pom.xml b/tests/pom.xml
new file mode 100644
index 0000000..a5e25db
--- /dev/null
+++ b/tests/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel.tests</groupId>
+ <artifactId>camel-tests-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tests</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>Camel Performance :: Tests</name>
+
+ <modules>
+ <module>camel-jmh</module>
+ </modules>
+
+</project>