This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-performance-tests.git

commit d18280655cd742d876dc12bacf811a0e4b9a43d1
Author: Otavio Rodolfo Piske <angusyo...@gmail.com>
AuthorDate: Thu May 11 12:34:19 2023 +0200

    (chores) performance: break disruptor tests
    
    Separate some tests that are only useful when running on large machines
---
 .../jmh/DisruptorMultipleTypesProducerTest.java    | 48 +++++-----------------
 .../camel/itest/jmh/DisruptorProducerTest.java     | 37 ++++-------------
 ....java => DisruptorScalabilityProducerTest.java} | 40 +++++-------------
 3 files changed, 28 insertions(+), 97 deletions(-)

diff --git 
a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorMultipleTypesProducerTest.java
 
b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorMultipleTypesProducerTest.java
index 4d82cd3..efee2cc 100644
--- 
a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorMultipleTypesProducerTest.java
+++ 
b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorMultipleTypesProducerTest.java
@@ -25,6 +25,12 @@ import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.options.Options;
 import org.openjdk.jmh.runner.options.OptionsBuilder;
 
+
+/**
+ * This tests the disruptor component when running with a small threads and 
exchanging data with different types. This is
+ * suitable for most cases when a large machine with too many cores is not 
available (as it limits to a maximum of 4 consumers
+ * + 4 producers).
+ */
 public class DisruptorMultipleTypesProducerTest {
 
     @Test
@@ -48,7 +54,7 @@ public class DisruptorMultipleTypesProducerTest {
     // 
http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
     @State(Scope.Benchmark)
     public static class BenchmarkState {
-        @Param({"1", "2", "4", "8", "16", "32"})
+        @Param({"1", "2", "4"})
         int consumers;
 
         CamelContext context;
@@ -78,7 +84,7 @@ public class DisruptorMultipleTypesProducerTest {
         }
     }
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     public void sendMultipleTypes_1(BenchmarkState state, Blackhole bh) {
@@ -88,7 +94,7 @@ public class DisruptorMultipleTypesProducerTest {
         state.producerTemplate.sendBody(state.endpoint, state.sampleFile);
     }
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     @Threads(2)
@@ -99,7 +105,7 @@ public class DisruptorMultipleTypesProducerTest {
         state.producerTemplate.sendBody(state.endpoint, state.sampleFile);
     }
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     @Threads(4)
@@ -109,38 +115,4 @@ public class DisruptorMultipleTypesProducerTest {
         state.producerTemplate.sendBody(state.endpoint, state.someLong);
         state.producerTemplate.sendBody(state.endpoint, state.sampleFile);
     }
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    @Threads(8)
-    public void sendBlockingWithMultipleTypes_8(BenchmarkState state, 
Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-        state.producerTemplate.sendBody(state.endpoint, state.someInt);
-        state.producerTemplate.sendBody(state.endpoint, state.someLong);
-        state.producerTemplate.sendBody(state.endpoint, state.sampleFile);
-    }
-
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    @Threads(16)
-    public void sendBlockingWithMultipleTypes_16(BenchmarkState state, 
Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-        state.producerTemplate.sendBody(state.endpoint, state.someInt);
-        state.producerTemplate.sendBody(state.endpoint, state.someLong);
-        state.producerTemplate.sendBody(state.endpoint, state.sampleFile);
-    }
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    @Threads(32)
-    public void sendBlockingWithMultipleTypes_32(BenchmarkState state, 
Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-        state.producerTemplate.sendBody(state.endpoint, state.someInt);
-        state.producerTemplate.sendBody(state.endpoint, state.someLong);
-        state.producerTemplate.sendBody(state.endpoint, state.sampleFile);
-    }
 }
diff --git 
a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorProducerTest.java
 
b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorProducerTest.java
index e13cbfb..2bc22ad 100644
--- 
a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorProducerTest.java
+++ 
b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorProducerTest.java
@@ -1,6 +1,5 @@
 package org.apache.camel.itest.jmh;
 
-import java.io.File;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
@@ -25,6 +24,10 @@ import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.options.Options;
 import org.openjdk.jmh.runner.options.OptionsBuilder;
 
+/**
+ * This tests the disruptor component when running with a small threads. This 
is suitable for most cases when
+ * a large machine with too many cores is not available (as it limits to a 
maximum of 4 consumers + 4 producers).
+ */
 public class DisruptorProducerTest {
 
     @Test
@@ -48,7 +51,7 @@ public class DisruptorProducerTest {
     // 
http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
     @State(Scope.Benchmark)
     public static class BenchmarkState {
-        @Param({"1", "2", "4", "8", "16", "32"})
+        @Param({"1", "2", "4"})
         int consumers;
 
         CamelContext context;
@@ -74,14 +77,14 @@ public class DisruptorProducerTest {
         }
     }
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     public void send_1(BenchmarkState state, Blackhole bh) {
         state.producerTemplate.sendBody(state.endpoint, "test");
     }
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     @Threads(2)
@@ -90,35 +93,11 @@ public class DisruptorProducerTest {
     }
 
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     @Threads(4)
     public void send_4(BenchmarkState state, Blackhole bh) {
         state.producerTemplate.sendBody(state.endpoint, "test");
     }
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    @Threads(8)
-    public void send_8(BenchmarkState state, Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-    }
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    @Threads(16)
-    public void send_16(BenchmarkState state, Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-    }
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    @Threads(32)
-    public void send_32(BenchmarkState state, Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-    }
 }
diff --git 
a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorProducerTest.java
 
b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorScalabilityProducerTest.java
similarity index 77%
copy from 
tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorProducerTest.java
copy to 
tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorScalabilityProducerTest.java
index e13cbfb..2840349 100644
--- 
a/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorProducerTest.java
+++ 
b/tests/camel-jmh/src/test/java/org/apache/camel/itest/jmh/DisruptorScalabilityProducerTest.java
@@ -1,6 +1,5 @@
 package org.apache.camel.itest.jmh;
 
-import java.io.File;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.CamelContext;
@@ -25,7 +24,12 @@ import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.options.Options;
 import org.openjdk.jmh.runner.options.OptionsBuilder;
 
-public class DisruptorProducerTest {
+/**
+ * This tests the scalability of the disruptor component when running with 
many threads. You need a large machine for running
+ * this reliably: desktops and machines with a small number of cores may 
introduce excessive scheduler latency affecting the
+ * results.
+ */
+public class DisruptorScalabilityProducerTest {
 
     @Test
     public void launchBenchmark() throws Exception {
@@ -48,7 +52,7 @@ public class DisruptorProducerTest {
     // 
http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
     @State(Scope.Benchmark)
     public static class BenchmarkState {
-        @Param({"1", "2", "4", "8", "16", "32"})
+        @Param({"1", "8", "16", "32"})
         int consumers;
 
         CamelContext context;
@@ -74,31 +78,7 @@ public class DisruptorProducerTest {
         }
     }
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    public void send_1(BenchmarkState state, Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-    }
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    @Threads(2)
-    public void send_2(BenchmarkState state, Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-    }
-
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
-    @BenchmarkMode(Mode.AverageTime)
-    @Benchmark
-    @Threads(4)
-    public void send_4(BenchmarkState state, Blackhole bh) {
-        state.producerTemplate.sendBody(state.endpoint, "test");
-    }
-
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     @Threads(8)
@@ -106,7 +86,7 @@ public class DisruptorProducerTest {
         state.producerTemplate.sendBody(state.endpoint, "test");
     }
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     @Threads(16)
@@ -114,7 +94,7 @@ public class DisruptorProducerTest {
         state.producerTemplate.sendBody(state.endpoint, "test");
     }
 
-    @OutputTimeUnit(TimeUnit.MILLISECONDS)
+    @OutputTimeUnit(TimeUnit.MICROSECONDS)
     @BenchmarkMode(Mode.AverageTime)
     @Benchmark
     @Threads(32)

Reply via email to