Author: justin
Date: Tue Jul 19 20:49:53 2011
New Revision: 1148519
URL: http://svn.apache.org/viewvc?rev=1148519&view=rev
Log:
SLING-1476 - adding microbenchmark for adding stats to the statistics object
Added:
sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/
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
Modified: sling/trunk/bundles/engine/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/engine/pom.xml?rev=1148519&r1=1148518&r2=1148519&view=diff
==============================================================================
--- sling/trunk/bundles/engine/pom.xml (original)
+++ sling/trunk/bundles/engine/pom.xml Tue Jul 19 20:49:53 2011
@@ -174,5 +174,72 @@
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.sun.japex</groupId>
+ <artifactId>japex</artifactId>
+ <version>1.2.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
+ <profiles>
+ <profile>
+ <id>benchmarks</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-commons-math-for-japex</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <configuration>
+
<includeArtifactIds>commons-math</includeArtifactIds>
+
<outputDirectory>${project.build.directory}/japex-dependency</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.sun.japex</groupId>
+ <artifactId>japex-maven-plugin</artifactId>
+ <version>1.2.3</version>
+ <executions>
+ <execution>
+ <id>japex</id>
+ <goals>
+ <goal>japex</goal>
+ </goals>
+ </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>
+ <testCase name="test" />
+ </testSuite>
+ </japexConfig>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added:
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=1148519&view=auto
==============================================================================
---
sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDirectDriver.java
(added)
+++
sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsDirectDriver.java
Tue Jul 19 20:49:53 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.sling.engine.benchmarks;
+
+import java.util.Random;
+
+import org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatistics;
+
+import com.sun.japex.JapexDriverBase;
+import com.sun.japex.TestCase;
+
+public class AddValueToStatisticsDirectDriver extends JapexDriverBase {
+
+ private SynchronizedSummaryStatistics statistics;
+
+ @Override
+ public void prepare(TestCase tc) {
+ this.statistics = new SynchronizedSummaryStatistics();
+ }
+
+ @Override
+ public void run(TestCase tc) {
+ Random random = new Random();
+ statistics.addValue(random.nextLong());
+ }
+
+}
Added:
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=1148519&view=auto
==============================================================================
---
sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsViaExecutorDriver.java
(added)
+++
sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/benchmarks/AddValueToStatisticsViaExecutorDriver.java
Tue Jul 19 20:49:53 2011
@@ -0,0 +1,51 @@
+/*
+ * 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.sling.engine.benchmarks;
+
+import java.util.Random;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatistics;
+
+import com.sun.japex.JapexDriverBase;
+import com.sun.japex.TestCase;
+
+public class AddValueToStatisticsViaExecutorDriver extends JapexDriverBase {
+
+ private SynchronizedSummaryStatistics statistics;
+ private ExecutorService operationExecutor;
+
+ @Override
+ public void prepare(TestCase tc) {
+ this.statistics = new SynchronizedSummaryStatistics();
+ this.operationExecutor = Executors.newSingleThreadExecutor();
+ }
+
+ @Override
+ public void run(TestCase tc) {
+ Random random = new Random();
+ final long value = random.nextLong();
+ operationExecutor.execute(new Runnable() {
+
+ public void run() {
+ statistics.addValue(value);
+ }
+ });
+ }
+
+}