Repository: camel Updated Branches: refs/heads/master df18d7d13 -> 40a5d7e04
Add camel-jmh tests Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/40a5d7e0 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/40a5d7e0 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/40a5d7e0 Branch: refs/heads/master Commit: 40a5d7e044305b7fd2fc6203435d9b122f627426 Parents: df18d7d Author: Claus Ibsen <[email protected]> Authored: Fri Jun 9 22:54:06 2017 +0200 Committer: Claus Ibsen <[email protected]> Committed: Fri Jun 9 22:54:06 2017 +0200 ---------------------------------------------------------------------- .../camel/itest/jmh/DefaultUuidGeneratorTest.java | 14 ++++++++------ .../org/apache/camel/itest/jmh/TypeConverterTest.java | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/40a5d7e0/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java index 138bec9..d049978 100644 --- a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java +++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DefaultUuidGeneratorTest.java @@ -21,8 +21,11 @@ import java.util.concurrent.TimeUnit; import org.apache.camel.impl.DefaultUuidGenerator; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; @@ -39,8 +42,6 @@ import org.openjdk.jmh.runner.options.TimeValue; */ public class DefaultUuidGeneratorTest { - private static final int LOOPS = 10000; - @Test public void launchBenchmark() throws Exception { Options opt = new OptionsBuilder() @@ -78,11 +79,12 @@ public class DefaultUuidGeneratorTest { } @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.MILLISECONDS) + @Measurement(batchSize = 1000) public void benchmark(BenchmarkState state, Blackhole bh) { - for (int i = 0; i < LOOPS; i++) { - String id = state.uuid.generateUuid(); - bh.consume(id); - } + String id = state.uuid.generateUuid(); + bh.consume(id); } } http://git-wip-us.apache.org/repos/asf/camel/blob/40a5d7e0/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java index 28df60a..c837dfd 100644 --- a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java +++ b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/TypeConverterTest.java @@ -23,8 +23,11 @@ import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.impl.DefaultUuidGenerator; import org.junit.Test; import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Level; +import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; @@ -40,8 +43,6 @@ import org.openjdk.jmh.runner.options.TimeValue; */ public class TypeConverterTest { - private static final int LOOPS = 10000; - @Test public void launchBenchmark() throws Exception { Options opt = new OptionsBuilder() @@ -94,11 +95,12 @@ public class TypeConverterTest { } @Benchmark + @BenchmarkMode(Mode.AverageTime) + @OutputTimeUnit(TimeUnit.MILLISECONDS) + @Measurement(batchSize = 1000) public void typeConvertIntegerToString(BenchmarkState state, Blackhole bh) { - for (int i = 0; i < LOOPS; i++) { - String id = state.camel.getTypeConverter().convertTo(String.class, i); - bh.consume(id); - } + String id = state.camel.getTypeConverter().convertTo(String.class, 12345); + bh.consume(id); } }
