You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by ju...@apache.org on 2013/02/25 09:41:52 UTC
svn commit: r1449617 - in
/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark:
AbstractTest.java Benchmark.java
Author: jukka
Date: Mon Feb 25 08:41:52 2013
New Revision: 1449617
URL: http://svn.apache.org/r1449617
Log:
OAK-641: Improved benchmark tooling
Refactor benchmark code to allow a wider range of different benchmarks
Modified:
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java?rev=1449617&r1=1449616&r2=1449617&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/AbstractTest.java Mon Feb 25 08:41:52 2013
@@ -18,11 +18,17 @@ package org.apache.jackrabbit.oak.benchm
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
import javax.jcr.Credentials;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
+import org.apache.jackrabbit.oak.fixture.RepositoryFixture;
/**
* Abstract base class for individual performance benchmarks.
@@ -66,6 +72,65 @@ public abstract class AbstractTest {
beforeSuite();
}
+ public void run(Map<String, RepositoryFixture> fixtures) throws Exception {
+ System.out.format(
+ "# %-34.34s min 10%% 50%% 90%% max N%n",
+ toString());
+ for (Map.Entry<String, RepositoryFixture> fixture : fixtures.entrySet()) {
+ Repository[] cluster = new Repository[1];
+ fixture.getValue().setUpCluster(cluster);
+ try {
+ // Run the test
+ DescriptiveStatistics statistics = runTest(cluster[0]);
+ if (statistics.getN() > 0) {
+ System.out.format(
+ "%-36.36s %6.0f %6.0f %6.0f %6.0f %6.0f %6d%n",
+ fixture.getKey(),
+ statistics.getMin(),
+ statistics.getPercentile(10.0),
+ statistics.getPercentile(50.0),
+ statistics.getPercentile(90.0),
+ statistics.getMax(),
+ statistics.getN());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ fixture.getValue().tearDownCluster(cluster);
+ }
+ }
+ }
+
+ private static final Credentials CREDENTIALS =
+ new SimpleCredentials("admin", "admin".toCharArray());
+
+ private DescriptiveStatistics runTest(Repository repository) throws Exception {
+ DescriptiveStatistics statistics = new DescriptiveStatistics();
+
+ setUp(repository, CREDENTIALS);
+ try {
+ // Run a few iterations to warm up the system
+ for (int i = 0; i < 5; i++) {
+ execute();
+ }
+
+ // Run test iterations, and capture the execution times
+ int iterations = 0;
+ long runtimeEnd =
+ System.currentTimeMillis()
+ + TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
+ while (iterations++ < 10
+ || System.currentTimeMillis() < runtimeEnd) {
+ statistics.addValue(execute());
+ }
+ } finally {
+ tearDown();
+ }
+
+ return statistics;
+ }
+
+
/**
* Executes a single iteration of this test.
*
Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java?rev=1449617&r1=1449616&r2=1449617&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/Benchmark.java Mon Feb 25 08:41:52 2013
@@ -16,19 +16,15 @@
*/
package org.apache.jackrabbit.oak.benchmark;
+import java.util.List;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import javax.jcr.Credentials;
-import javax.jcr.Repository;
-import javax.jcr.SimpleCredentials;
-
-import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
import org.apache.jackrabbit.oak.fixture.JackrabbitRepositoryFixture;
import org.apache.jackrabbit.oak.fixture.OakRepositoryFixture;
import org.apache.jackrabbit.oak.fixture.RepositoryFixture;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
public class Benchmark {
@@ -64,12 +60,12 @@ public class Benchmark {
public static void main(String[] args) throws Exception {
Map<String, RepositoryFixture> fixtures = Maps.newLinkedHashMap();
- Map<String, AbstractTest> tests = Maps.newLinkedHashMap();
+ List<AbstractTest> tests = Lists.newArrayList();
for (String name : args) {
if (FIXTURES.containsKey(name)) {
fixtures.put(name, FIXTURES.get(name));
} else if (TESTS.containsKey(name)) {
- tests.put(name, TESTS.get(name));
+ tests.add(TESTS.get(name));
} else {
throw new RuntimeException("Unknown argument: " + name);
}
@@ -78,66 +74,12 @@ public class Benchmark {
fixtures.putAll(FIXTURES);
}
if (tests.isEmpty()) {
- tests.putAll(TESTS);
+ tests.addAll(TESTS.values());
}
- for (Map.Entry<String, AbstractTest> test : tests.entrySet()) {
- System.out.format(
- "# %-34.34s min 10%% 50%% 90%% max%n",
- test.getKey());
- for (Map.Entry<String, RepositoryFixture> fixture : fixtures.entrySet()) {
- Repository[] cluster = new Repository[1];
- fixture.getValue().setUpCluster(cluster);
- try {
- // Run the test
- DescriptiveStatistics statistics =
- runTest(test.getValue(), cluster[0]);
- if (statistics.getN() > 0) {
- System.out.format(
- "%-36.36s %6.0f %6.0f %6.0f %6.0f %6.0f%n",
- fixture.getKey(),
- statistics.getMin(),
- statistics.getPercentile(10.0),
- statistics.getPercentile(50.0),
- statistics.getPercentile(90.0), statistics.getMax());
- }
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- fixture.getValue().tearDownCluster(cluster);
- }
- }
- }
- }
-
- private static final Credentials CREDENTIALS =
- new SimpleCredentials("admin", "admin".toCharArray());
-
- private static DescriptiveStatistics runTest(AbstractTest test,
- Repository repository) throws Exception {
- DescriptiveStatistics statistics = new DescriptiveStatistics();
-
- test.setUp(repository, CREDENTIALS);
- try {
- // Run a few iterations to warm up the system
- for (int i = 0; i < 5; i++) {
- test.execute();
- }
-
- // Run test iterations, and capture the execution times
- int iterations = 0;
- long runtimeEnd =
- System.currentTimeMillis()
- + TimeUnit.MILLISECONDS.convert(1, TimeUnit.MINUTES);
- while (iterations++ < 10
- || System.currentTimeMillis() < runtimeEnd) {
- statistics.addValue(test.execute());
- }
- } finally {
- test.tearDown();
+ for (AbstractTest test : tests) {
+ test.run(fixtures);
}
-
- return statistics;
}
}