incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1148949 - in /sling/trunk/bundles/engine: ./ src/main/java/org/apache/sling/engine/jmx/ src/test/java/org/apache/sling/engine/benchmarks/ src/test/resources/ src/test/resources/japex/
Date Wed, 20 Jul 2011 21:52:49 GMT
Author: justin
Date: Wed Jul 20 21:52:47 2011
New Revision: 1148949

URL: http://svn.apache.org/viewvc?rev=1148949&view=rev
Log:
SLING-1476 - updating benchmarks and switchin implementation to do direct addition to the
statistics object

Added:
    sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToAtomicsDriver.java
      - copied, changed from r1148867, sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDriver.java
    sling/trunk/bundles/engine/src/test/resources/
    sling/trunk/bundles/engine/src/test/resources/japex/
    sling/trunk/bundles/engine/src/test/resources/japex/hundred_iterations.xml
    sling/trunk/bundles/engine/src/test/resources/japex/million_iterations.xml
    sling/trunk/bundles/engine/src/test/resources/japex/thousand_iterations.xml
Removed:
    sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDriver.java
Modified:
    sling/trunk/bundles/engine/pom.xml
    sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/jmx/RequestProcessor.java
    sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDirectDriver.java
    sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsViaExecutorDriver.java

Modified: sling/trunk/bundles/engine/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/pom.xml?rev=1148949&r1=1148948&r2=1148949&view=diff
==============================================================================
--- sling/trunk/bundles/engine/pom.xml (original)
+++ sling/trunk/bundles/engine/pom.xml Wed Jul 20 21:52:47 2011
@@ -215,31 +215,11 @@
                             </execution>
                         </executions>
                         <configuration>
-                            <japexConfig>
-                                <testSuite name="StatisticsTest"
-                                    xmlns="http://www.sun.com/japex/testSuite">
-                                    <param name="japex.classPath" value="${project.build.outputDirectory}"
/>
-                                    <param name="japex.classPath" value="${project.build.testOutputDirectory}"
/>
-                                    <param name="japex.classPath" value="${project.build.directory}/japex-dependency/*.jar"
/>
-                                    <param name="japex.resultUnit" value="ms" />
-                                    <param name="japex.warmupIterations" value="5" />
-                                    <param name="japex.runIterations" value="1000" />
-                                    <param name="japex.numberOfThreads" value="50" />
-                                    <driver name="AddToStatsDirect">
-                                        <param name="japex.driverClass" value="org.apache.sling.engine.benchmarks.AddValueToStatisticsDirectDriver"
/>
-                                        <param name="description" value="Add a value to
statistics through direct invocation." />
-                                    </driver>
-                                    <driver name="AddToStatsViaExecutor">
-                                        <param name="japex.driverClass" value="org.apache.sling.engine.benchmarks.AddValueToStatisticsViaExecutorDriver"
/>
-                                        <param name="description" value="Add a value to
statistics via a separate thread." />
-                                    </driver>
-                                    <driver name="AddToStats">
-                                        <param name="japex.driverClass" value="org.apache.sling.engine.benchmarks.AddValueToStatisticsDriver"
/>
-                                        <param name="description" value="Add a value to
statistics using atomic objects." />
-                                    </driver>
-                                    <testCase name="test" />
-                                </testSuite>
-                            </japexConfig>
+                            <japexConfigFiles>
+                                <file>src/test/resources/japex/hundred_iterations.xml</file>
+                                <file>src/test/resources/japex/thousand_iterations.xml</file>
+                                <file>src/test/resources/japex/million_iterations.xml</file>
+                            </japexConfigFiles>
                         </configuration>
                     </plugin>
                 </plugins>

Modified: sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/jmx/RequestProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/jmx/RequestProcessor.java?rev=1148949&r1=1148948&r2=1148949&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/jmx/RequestProcessor.java
(original)
+++ sling/trunk/bundles/engine/src/main/java/org/apache/sling/engine/jmx/RequestProcessor.java
Wed Jul 20 21:52:47 2011
@@ -27,21 +27,13 @@ import org.apache.commons.math.stat.desc
 public class RequestProcessor implements RequestProcessorMBean {
 
     private final SynchronizedSummaryStatistics durationStatistics;
-    
-    private final ExecutorService operationExecutor;
 
     public RequestProcessor() {
         this.durationStatistics = new SynchronizedSummaryStatistics();
-        this.operationExecutor = Executors.newSingleThreadExecutor();
     }
 
     public void addRequestDuration(final long value) {
-        operationExecutor.execute(new Runnable() {
-
-            public void run() {
-                durationStatistics.addValue(value);
-            }
-        });
+        durationStatistics.addValue(value);
     }
 
     public long getCount() {
@@ -53,13 +45,7 @@ public class RequestProcessor implements
     }
     
     public void resetStatistics() {
-        operationExecutor.execute(new Runnable() {
-            
-            public void run() {
-                durationStatistics.clear();
-                
-            }
-        });
+        durationStatistics.clear();
     }
 
 }

Copied: sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToAtomicsDriver.java
(from r1148867, sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDriver.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToAtomicsDriver.java?p2=sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToAtomicsDriver.java&p1=sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDriver.java&r1=1148867&r2=1148949&rev=1148949&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDriver.java
(original)
+++ sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToAtomicsDriver.java
Wed Jul 20 21:52:47 2011
@@ -17,26 +17,30 @@
 package org.apache.sling.engine.benchmarks;
 
 import java.util.Random;
-
-import org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatistics;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 
 import com.sun.japex.JapexDriverBase;
 import com.sun.japex.TestCase;
 
-public class AddValueToStatisticsDriver extends JapexDriverBase {
+public class AddValueToAtomicsDriver extends JapexDriverBase {
 
     private final Random random = new Random();
 
-    private SynchronizedSummaryStatistics statistics;
+    private AtomicInteger count;
+
+    private AtomicLong sum;
 
     @Override
     public void prepare(TestCase tc) {
-        this.statistics = new SynchronizedSummaryStatistics();
+        this.count = new AtomicInteger();
+        this.sum = new AtomicLong();
     }
 
     @Override
     public void run(TestCase tc) {
-        statistics.addValue(random.nextLong());
+        this.count.incrementAndGet();
+        this.sum.addAndGet(random.nextLong());
     }
 
 }

Modified: sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDirectDriver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDirectDriver.java?rev=1148949&r1=1148948&r2=1148949&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDirectDriver.java
(original)
+++ sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDirectDriver.java
Wed Jul 20 21:52:47 2011
@@ -17,8 +17,8 @@
 package org.apache.sling.engine.benchmarks;
 
 import java.util.Random;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatistics;
 
 import com.sun.japex.JapexDriverBase;
 import com.sun.japex.TestCase;
@@ -27,20 +27,16 @@ public class AddValueToStatisticsDirectD
 
     private final Random random = new Random();
 
-    private AtomicInteger count;
-
-    private AtomicLong sum;
+    private SynchronizedSummaryStatistics statistics;
 
     @Override
     public void prepare(TestCase tc) {
-        this.count = new AtomicInteger();
-        this.sum = new AtomicLong();
+        this.statistics = new SynchronizedSummaryStatistics();
     }
 
     @Override
     public void run(TestCase tc) {
-        this.count.incrementAndGet();
-        this.sum.addAndGet(random.nextLong());
+        statistics.addValue(random.nextLong());
     }
 
 }

Modified: sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsViaExecutorDriver.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsViaExecutorDriver.java?rev=1148949&r1=1148948&r2=1148949&view=diff
==============================================================================
--- sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsViaExecutorDriver.java
(original)
+++ sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsViaExecutorDriver.java
Wed Jul 20 21:52:47 2011
@@ -19,6 +19,7 @@ package org.apache.sling.engine.benchmar
 import java.util.Random;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatistics;
 
@@ -48,5 +49,15 @@ public class AddValueToStatisticsViaExec
             }
         });
     }
+    /*
+    @Override
+    public void finish(TestCase testCase) {
+        operationExecutor.shutdown();
+        try {
+            operationExecutor.awaitTermination(30, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }*/
 
 }

Added: sling/trunk/bundles/engine/src/test/resources/japex/hundred_iterations.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/test/resources/japex/hundred_iterations.xml?rev=1148949&view=auto
==============================================================================
--- sling/trunk/bundles/engine/src/test/resources/japex/hundred_iterations.xml (added)
+++ sling/trunk/bundles/engine/src/test/resources/japex/hundred_iterations.xml Wed Jul 20
21:52:47 2011
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<testSuite name="StatisticsTest" xmlns="http://www.sun.com/japex/testSuite">
+    <param name="japex.classPath" value="target/classes" />
+    <param name="japex.classPath" value="target/test-classes" />
+    <param name="japex.classPath" value="target/japex-dependency/*.jar" />
+    <param name="japex.resultUnit" value="ms" />
+    <param name="japex.warmupIterations" value="5" />
+    <param name="japex.runIterations" value="100" />
+    <param name="japex.numberOfThreads" value="50" />
+    <driver name="AddToStatsDirect">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToStatisticsDirectDriver" />
+        <param name="description"
+            value="Add a value to statistics through direct invocation." />
+    </driver>
+    <driver name="AddToStatsViaExecutor">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToStatisticsViaExecutorDriver"
/>
+        <param name="description"
+            value="Add a value to statistics via a separate thread." />
+    </driver>
+    <driver name="AddToAtomics">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToAtomicsDriver" />
+        <param name="description"
+            value="Add values to some atomic objects." />
+    </driver>
+    <testCase name="hundred_test" />
+</testSuite>
\ No newline at end of file

Added: sling/trunk/bundles/engine/src/test/resources/japex/million_iterations.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/test/resources/japex/million_iterations.xml?rev=1148949&view=auto
==============================================================================
--- sling/trunk/bundles/engine/src/test/resources/japex/million_iterations.xml (added)
+++ sling/trunk/bundles/engine/src/test/resources/japex/million_iterations.xml Wed Jul 20
21:52:47 2011
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<testSuite name="StatisticsTest" xmlns="http://www.sun.com/japex/testSuite">
+    <param name="japex.classPath" value="target/classes" />
+    <param name="japex.classPath" value="target/test-classes" />
+    <param name="japex.classPath" value="target/japex-dependency/*.jar" />
+    <param name="japex.resultUnit" value="ms" />
+    <param name="japex.warmupIterations" value="5" />
+    <param name="japex.runIterations" value="1000000" />
+    <param name="japex.numberOfThreads" value="50" />
+    <driver name="AddToStatsDirect">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToStatisticsDirectDriver" />
+        <param name="description"
+            value="Add a value to statistics through direct invocation." />
+    </driver>
+    <driver name="AddToStatsViaExecutor">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToStatisticsViaExecutorDriver"
/>
+        <param name="description"
+            value="Add a value to statistics via a separate thread." />
+    </driver>
+    <driver name="AddToAtomics">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToAtomicsDriver" />
+        <param name="description"
+            value="Add values to some atomic objects." />
+    </driver>
+    <testCase name="million_test" />
+</testSuite>
\ No newline at end of file

Added: sling/trunk/bundles/engine/src/test/resources/japex/thousand_iterations.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/engine/src/test/resources/japex/thousand_iterations.xml?rev=1148949&view=auto
==============================================================================
--- sling/trunk/bundles/engine/src/test/resources/japex/thousand_iterations.xml (added)
+++ sling/trunk/bundles/engine/src/test/resources/japex/thousand_iterations.xml Wed Jul 20
21:52:47 2011
@@ -0,0 +1,47 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+<testSuite name="StatisticsTest" xmlns="http://www.sun.com/japex/testSuite">
+    <param name="japex.classPath" value="target/classes" />
+    <param name="japex.classPath" value="target/test-classes" />
+    <param name="japex.classPath" value="target/japex-dependency/*.jar" />
+    <param name="japex.resultUnit" value="ms" />
+    <param name="japex.warmupIterations" value="5" />
+    <param name="japex.runIterations" value="1000" />
+    <param name="japex.numberOfThreads" value="50" />
+    <driver name="AddToStatsDirect">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToStatisticsDirectDriver" />
+        <param name="description"
+            value="Add a value to statistics through direct invocation." />
+    </driver>
+    <driver name="AddToStatsViaExecutor">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToStatisticsViaExecutorDriver"
/>
+        <param name="description"
+            value="Add a value to statistics via a separate thread." />
+    </driver>
+    <driver name="AddToAtomics">
+        <param name="japex.driverClass"
+            value="org.apache.sling.engine.benchmarks.AddValueToAtomicsDriver" />
+        <param name="description"
+            value="Add values to some atomic objects." />
+    </driver>
+    <testCase name="thousand_test" />
+</testSuite>
\ No newline at end of file



Mime
View raw message