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

svn commit: r801588 - in /camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor: RoutePerformanceCountTest.java RoutePerformanceTest.java

Author: davsclaus
Date: Thu Aug  6 10:10:09 2009
New Revision: 801588

URL: http://svn.apache.org/viewvc?rev=801588&view=rev
Log:
Added performance test not using mocks

Added:
    camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java   (with props)
Modified:
    camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java

Added: camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java?rev=801588&view=auto
==============================================================================
--- camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java (added)
+++ camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java Thu Aug  6 10:10:09 2009
@@ -0,0 +1,87 @@
+/**
+ * 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.processor;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision$
+ */
+public class RoutePerformanceCountTest extends ContextTestSupport {
+
+    private CountProcessor processor = new CountProcessor();
+    private int size = 10000;
+    private String url = "direct:start";
+
+    public void testSendMessages() throws Exception {
+        if (!canRunOnThisPlatform()) {
+            return;
+        }
+
+        long start = System.currentTimeMillis();
+
+        for (int i = 0; i < size; i++) {
+            template.sendBody(url, "Message " + i);
+        }
+        assertEquals(size, processor.getCounter());
+
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("RoutePerformanceCountTest: Sent: " + size + " Took: " + delta + " ms");
+    }
+
+    private boolean canRunOnThisPlatform() {
+        String os = System.getProperty("os.name");
+        // HP-UX is just to slow to run this test
+        return !os.toLowerCase().contains("hp-ux");
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").to("log:a?level=OFF", "log:b?level=OFF", "direct:c");
+
+                from("direct:c")
+                    .choice()
+                        .when().header("foo").process(processor)
+                        .otherwise().process(processor)
+                    .end();
+            }
+        };
+    }
+
+    private class CountProcessor implements Processor {
+
+        private AtomicInteger counter = new AtomicInteger(0);
+
+        public void process(Exchange exchange) throws Exception {
+            counter.incrementAndGet();
+        }
+
+        public int getCounter() {
+            return counter.intValue();
+        }
+
+    }
+
+}

Propchange: camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceCountTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
URL: http://svn.apache.org/viewvc/camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java?rev=801588&r1=801587&r2=801588&view=diff
==============================================================================
--- camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java (original)
+++ camel/sandbox/tuning-experiment/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java Thu Aug  6 10:10:09 2009
@@ -31,7 +31,7 @@
  */
 public class RoutePerformanceTest extends ContextTestSupport {
 
-    private int size = 20000;
+    private int size = 10000;
     private SimpleDataSet dataSet = new SimpleDataSet(size);
     private String uri = "mock:results";