You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2010/03/10 15:21:43 UTC

svn commit: r921362 - in /jackrabbit/commons/jcr-benchmark/trunk: ./ src/main/java/org/apache/jackrabbit/benchmark/

Author: jukka
Date: Wed Mar 10 14:21:42 2010
New Revision: 921362

URL: http://svn.apache.org/viewvc?rev=921362&view=rev
Log:
benchmark: Fleshing out some ideas on different benchmark tests.

Added:
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginLogoutTest.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTest.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java   (with props)
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TestInputStream.java   (with props)
Removed:
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BenchmarkSuite.java
Modified:
    jackrabbit/commons/jcr-benchmark/trunk/pom.xml
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginTest.java
    jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/RefreshTest.java

Modified: jackrabbit/commons/jcr-benchmark/trunk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/pom.xml?rev=921362&r1=921361&r2=921362&view=diff
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/pom.xml (original)
+++ jackrabbit/commons/jcr-benchmark/trunk/pom.xml Wed Mar 10 14:21:42 2010
@@ -26,11 +26,11 @@
   <parent>
     <groupId>org.apache.jackrabbit</groupId>
     <artifactId>parent</artifactId>
-    <version>3</version>
+    <version>5</version>
   </parent>
 
   <artifactId>jackrabbit-jcr-benchmark</artifactId>
-  <version>1.6-SNAPSHOT</version>
+  <version>2.0-SNAPSHOT</version>
   <name>Jackrabbit JCR Benchmarks</name>
   <description>
     JCR Benchmark is a suite of performance and scalability tests for
@@ -51,23 +51,40 @@
     <dependency>
       <groupId>javax.jcr</groupId>
       <artifactId>jcr</artifactId>
-      <version>1.0</version>
+      <version>2.0</version>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-math</artifactId>
+      <version>2.0</version>
     </dependency>
     <dependency>
-      <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-      <version>1.5.3</version>
+      <groupId>org.apache.jackrabbit</groupId>
+      <artifactId>jackrabbit-jcr-tests</artifactId>
+      <version>2.1-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
-      <artifactId>jackrabbit-jcr-tests</artifactId>
-      <version>1.5.0</version>
+      <artifactId>jackrabbit-core</artifactId>
+      <version>2.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-nop</artifactId>
+      <version>1.5.8</version>
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <target>1.5</target>
+          <source>1.5</source>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
 </project>

Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java?rev=921362&r1=921361&r2=921362&view=diff
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java (original)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigCollectionTest.java Wed Mar 10 14:21:42 2010
@@ -91,7 +91,7 @@ public class BigCollectionTest extends A
         long cnt = 0;
 
         while (System.currentTimeMillis() - start < MINTIME || cnt < MINCOUNT) {
-            Session s = helper.getReadOnlySession();
+            Session s = getHelper().getReadOnlySession();
             try {
                 Node dir = (Node) s.getItem(bigcollPath);
                 int members = 0;

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java?rev=921362&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java Wed Mar 10 14:21:42 2010
@@ -0,0 +1,86 @@
+/*
+ * 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.jackrabbit.benchmark;
+
+import java.util.Calendar;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.io.output.NullOutputStream;
+
+public class BigFileReadTest extends PerformanceTest {
+
+    private static final int FILE_COUNT = 10;
+
+    private static final int FILE_SIZE = 100;
+
+    private Session session;
+
+    private Node root;
+
+    private int i = 0;
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+
+        root = session.getRootNode().addNode(
+                "BigFileReadTest", NodeType.NT_FOLDER);
+        for (int i = 0; i < FILE_COUNT; i++) {
+            Node file = root.addNode("file" + i, NodeType.NT_FILE);
+            Node content = file.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE);
+            content.setProperty(Property.JCR_MIMETYPE, "application/octet-stream");
+            content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance());
+            Binary binary = session.getValueFactory().createBinary(
+                    new TestInputStream(FILE_SIZE * 1024 * 1024));
+            try {
+                content.setProperty(Property.JCR_DATA, binary);
+            } finally {
+                binary.dispose();
+            }
+        }
+        session.save();
+    }
+
+    public void runTest() throws Exception {
+        Node file = root.getNode("file" + (i++ % FILE_COUNT));
+        Node content = file.getNode(Node.JCR_CONTENT);
+        Property data = content.getProperty(Property.JCR_DATA);
+        Binary binary = data.getBinary();
+        try {
+            IOUtils.copy(binary.getStream(), new NullOutputStream());
+        } finally {
+            binary.dispose();
+        }
+    }
+
+    public void afterSuite() throws RepositoryException {
+        root.remove();
+        session.save();
+        session.logout();
+    }
+
+    public String toString() {
+        return "read a " + FILE_SIZE + "MB file";
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileReadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java?rev=921362&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java Wed Mar 10 14:21:42 2010
@@ -0,0 +1,69 @@
+/*
+ * 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.jackrabbit.benchmark;
+
+import java.util.Calendar;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+public class BigFileWriteTest extends PerformanceTest {
+
+    private static final int FILE_SIZE = 100;
+
+    private Session session;
+
+    private Node file;
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+    }
+
+    public void runTest() throws RepositoryException {
+        file = session.getRootNode().addNode(
+                "BigFileWriteTest", NodeType.NT_FILE);
+        Node content = file.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE);
+        content.setProperty(Property.JCR_MIMETYPE, "application/octet-stream");
+        content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance());
+        Binary binary = session.getValueFactory().createBinary(
+                new TestInputStream(FILE_SIZE * 1024 * 1024));
+        try {
+            content.setProperty(Property.JCR_DATA, binary);
+        } finally {
+            binary.dispose();
+        }
+        session.save();
+    }
+
+    public void afterTest() throws RepositoryException {
+        file.remove();
+        session.save();
+    }
+
+    public void afterSuite() throws RepositoryException {
+        session.logout();
+    }
+
+    public String toString() {
+        return "write a " + FILE_SIZE + "MB file";
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/BigFileWriteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginLogoutTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginLogoutTest.java?rev=921362&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginLogoutTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginLogoutTest.java Wed Mar 10 14:21:42 2010
@@ -0,0 +1,33 @@
+/*
+ * 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.jackrabbit.benchmark;
+
+import javax.jcr.RepositoryException;
+
+public class LoginLogoutTest extends PerformanceTest {
+
+    public void runTest() throws RepositoryException {
+        for (int i = 0; i < 1000; i++) {
+            getRepository().login().logout();
+        }
+    }
+
+    public String toString() {
+        return "1000 x login().logout()";
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginLogoutTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginTest.java?rev=921362&r1=921361&r2=921362&view=diff
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginTest.java (original)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/LoginTest.java Wed Mar 10 14:21:42 2010
@@ -16,55 +16,27 @@
  */
 package org.apache.jackrabbit.benchmark;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
-import javax.jcr.Credentials;
 
-/** <code>LoginTest</code>... */
-public class LoginTest extends AbstractJCRTest {
+public class LoginTest extends PerformanceTest {
 
-    private static Logger log = LoggerFactory.getLogger(LoginTest.class);
+    private final Session[] sessions = new Session[1000];
 
-    private static int MINTIME = 500;
-    private static int MINCOUNT = 5;
-
-    private void performTest(String testName, Credentials creds, boolean accessRoot) throws RepositoryException {
-        long start = System.currentTimeMillis();
-        long cnt = 0;
-
-        while (System.currentTimeMillis() - start < MINTIME || cnt < MINCOUNT) {
-            Session s = helper.getRepository().login(creds);
-            try {
-                if (accessRoot) {
-                    s.getRootNode();
-                }
-            } finally {
-                s.logout();
-            }
-            cnt++;
+    public void runTest() throws RepositoryException {
+        for (int i = 0; i < sessions.length; i++) {
+            sessions[i] = getRepository().login();
         }
-
-        long elapsed = System.currentTimeMillis() - start;
-        log.info(testName + ": " +  (double)elapsed / cnt + "ms per call (" + cnt + " iterations)");
-    }
-
-    public void testLoginReadOnly() throws RepositoryException {
-        performTest("testLoginReadOnly", helper.getReadOnlyCredentials(), false);
     }
 
-    public void testLoginSuperuser() throws RepositoryException {
-        performTest("testLoginSuperuser", helper.getSuperuserCredentials(), false);
+    public void afterTest() throws RepositoryException {
+        for (int i = 0; i < sessions.length; i++) {
+            sessions[i].logout();
+        }
     }
 
-    public void testLoginReadWrite() throws RepositoryException {
-        performTest("testLoginReadWrite", helper.getReadWriteCredentials(), false);
+    public String toString() {
+        return "1000 x login()";
     }
 
-    public void testLoginAccessRoot() throws RepositoryException {
-        performTest("testLoginAccessRoot", helper.getReadOnlyCredentials(), true);
-    }
-}
\ No newline at end of file
+}

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTest.java?rev=921362&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTest.java Wed Mar 10 14:21:42 2010
@@ -0,0 +1,63 @@
+/*
+ * 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.jackrabbit.benchmark;
+
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+
+public abstract class PerformanceTest {
+
+    private Repository repository;
+
+    private Credentials credentials;
+
+    public void beforeSuite() throws Exception {
+    }
+
+    public void beforeTest() throws Exception {
+    }
+
+    public abstract void runTest() throws Exception;
+
+    public void afterTest() throws Exception {
+    }
+
+    public void afterSuite() throws Exception {
+    }
+
+    public Repository getRepository() {
+        return repository;
+    }
+
+    void setRepository(Repository repository) {
+        this.repository = repository;
+    }
+
+    public Credentials getCredentials() {
+        return credentials;
+    }
+
+    void setCredentials(Credentials credentials) {
+        this.credentials = credentials;
+    }
+
+    public String toString() {
+        String name = getClass().getName();
+        return name.substring(name.lastIndexOf('.') + 1);
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java?rev=921362&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java Wed Mar 10 14:21:42 2010
@@ -0,0 +1,142 @@
+/*
+ * 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.jackrabbit.benchmark;
+
+import java.io.File;
+
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.math.stat.descriptive.SummaryStatistics;
+import org.apache.jackrabbit.api.management.DataStoreGarbageCollector;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.SessionImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+
+public class PerformanceTestSuite {
+
+    private final Repository repository;
+
+    private final Credentials credentials;
+
+    private final int warmup = 10;
+
+    private final int runtime = 50;
+
+    public PerformanceTestSuite(
+            Repository repository, Credentials credentials) {
+        this.repository = repository;
+        this.credentials = credentials;
+    }
+
+    private void runTest(PerformanceTest test) throws Exception {
+        SummaryStatistics statistics = new SummaryStatistics();
+
+        test.setRepository(repository);
+        test.setCredentials(credentials);
+
+        test.beforeSuite();
+
+        // Run a few iterations to warm up the system
+        long warmupEnd = System.currentTimeMillis() + warmup * 1000;
+        while (System.currentTimeMillis() < warmupEnd) {
+            test.beforeTest();
+            test.runTest();
+            test.afterTest();
+        }
+
+        // Run test iterations, and capture the execution times
+        long runtimeEnd = System.currentTimeMillis() + runtime * 1000;
+        while (System.currentTimeMillis() < runtimeEnd) {
+            test.beforeTest();
+            long start = System.currentTimeMillis();
+            test.runTest();
+            statistics.addValue(System.currentTimeMillis() - start);
+            test.afterTest();
+        }
+
+        test.afterSuite();
+
+        System.out.format(
+                "%-36.36s  %6.0f  %6.0f  %6.0f  %6.0f  %6d%n",
+                test,
+                statistics.getMean(),
+                statistics.getStandardDeviation(),
+                statistics.getMin(),
+                statistics.getMax(),
+                statistics.getN());
+
+        SessionImpl session = (SessionImpl) repository.login(credentials);
+        DataStoreGarbageCollector collector =
+            session.createDataStoreGarbageCollector();
+        collector.mark();
+        collector.sweep();
+        collector.close();
+    }
+
+    public static void main(String[] args) throws Exception {
+        File file = new File("target", "repository");
+        RepositoryImpl repository =
+            RepositoryImpl.create(RepositoryConfig.install(file));
+        Credentials credentials =
+            new SimpleCredentials("admin", "admin".toCharArray());
+
+        System.out.println(
+                "Test case                           "
+                + "    Mean    Sdev     Min     Max   Count");
+        System.out.println(
+                "------------------------------------"
+                + "----------------------------------------");
+        PerformanceTestSuite suite =
+            new PerformanceTestSuite(repository, credentials);
+        suite.runTest(new LoginTest());
+        suite.runTest(new LoginLogoutTest());
+        // suite.runTest(new RefreshTest());
+        // suite.runTest(new SmallFileReadTest());
+        // suite.runTest(new SmallFileWriteTest());
+        // suite.runTest(new BigFileReadTest());
+        // suite.runTest(new BigFileWriteTest());
+
+        System.out.println();
+        System.out.println("Test environment");
+        System.out.format(
+                "  JCR: %s version %s by %s%n",
+                repository.getDescriptor(Repository.REP_NAME_DESC),
+                repository.getDescriptor(Repository.REP_VERSION_DESC),
+                repository.getDescriptor(Repository.REP_VENDOR_DESC));
+        System.out.format(
+                "  JRE: %s by %s%n",
+                System.getProperty("java.version"),
+                System.getProperty("java.vendor"));
+        System.out.format(
+                "  JVM: %s version %s by %s%n",
+                System.getProperty("java.vm.name"),
+                System.getProperty("java.vm.version"),
+                System.getProperty("java.vm.vendor"));
+        System.out.format(
+                "   OS: %s version %s for %s%n",
+                System.getProperty("os.name"),
+                System.getProperty("os.version"),
+                System.getProperty("os.arch"));
+
+        repository.shutdown();
+        FileUtils.deleteDirectory(file);
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/PerformanceTestSuite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/RefreshTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/RefreshTest.java?rev=921362&r1=921361&r2=921362&view=diff
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/RefreshTest.java (original)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/RefreshTest.java Wed Mar 10 14:21:42 2010
@@ -16,56 +16,29 @@
  */
 package org.apache.jackrabbit.benchmark;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
-/**
- * Several tests for benchmarking the performance when refreshing the complete
- * tree (containing "big" collections).
- * <p>
- * Assumes the store supports nt:folder/nt:file/nt:resource below
- * the test root node.
- */
-public class RefreshTest extends AbstractBenchmarkTest {
+public class RefreshTest extends PerformanceTest {
 
-    private static final Logger log = LoggerFactory.getLogger(RefreshTest.class);
+    private Session session;
 
-    protected String getCollectionName() {
-        return "folder";
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login();
     }
 
-    private void performTest(String testName, boolean refreshFlag) throws RepositoryException {
-        Session session = testRootNode.getSession();
-        long start = System.currentTimeMillis();
-        long cnt = 0;
-
-        while (System.currentTimeMillis() - start < RefreshTest.MINTIME || cnt < RefreshTest.MINCOUNT) {
-            Node dir = testRootNode.getNode(getCollectionName());
-            NodeIterator it = dir.getNodes();
-            testRootNode.refresh(refreshFlag);
-            cnt += 1;
+    public void runTest() throws Exception {
+        for (int i = 0; i < 1000000; i++) {
+            session.refresh(false);
         }
-
-        long elapsed = System.currentTimeMillis() - start;
-        log.info(testName + ": " +  (double)elapsed / cnt + "ms per call (" + cnt + " iterations)");
     }
 
-    /**
-     * Get all children, but do not visit jcr:content child nodes
-     */
-    public void testRefreshFalse() throws RepositoryException {
-        performTest("testRefreshFalse", false);
+    public void afterSuite() throws RepositoryException {
+        session.logout();
     }
 
-    /**
-     * Get all children, but do not visit jcr:content child nodes
-     */
-    public void testRefreshTrue() throws RepositoryException {
-        performTest("testRefreshTrue", true);
+    public String toString() {
+        return "1 000 000 x refresh(false)";
     }
+
 }

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java?rev=921362&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java Wed Mar 10 14:21:42 2010
@@ -0,0 +1,86 @@
+/*
+ * 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.jackrabbit.benchmark;
+
+import java.util.Calendar;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.io.output.NullOutputStream;
+
+public class SmallFileReadTest extends PerformanceTest {
+
+    private static final int FILE_COUNT = 1000;
+
+    private static final int FILE_SIZE = 10;
+
+    private Session session;
+
+    private Node root;
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+
+        root = session.getRootNode().addNode(
+                "SmallFileReadTest", NodeType.NT_FOLDER);
+        for (int i = 0; i < FILE_COUNT; i++) {
+            Node file = root.addNode("file" + i, NodeType.NT_FILE);
+            Node content = file.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE);
+            content.setProperty(Property.JCR_MIMETYPE, "application/octet-stream");
+            content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance());
+            Binary binary = session.getValueFactory().createBinary(
+                    new TestInputStream(FILE_SIZE * 1024));
+            try {
+                content.setProperty(Property.JCR_DATA, binary);
+            } finally {
+                binary.dispose();
+            }
+        }
+        session.save();
+    }
+
+    public void runTest() throws Exception {
+        for (int i = 0; i < FILE_COUNT; i++) {
+            Node file = root.getNode("file" + i);
+            Node content = file.getNode(Node.JCR_CONTENT);
+            Property data = content.getProperty(Property.JCR_DATA);
+            Binary binary = data.getBinary();
+            try {
+                IOUtils.copy(binary.getStream(), new NullOutputStream());
+            } finally {
+                binary.dispose();
+            }
+        }
+    }
+
+    public void afterSuite() throws RepositoryException {
+        root.remove();
+        session.save();
+        session.logout();
+    }
+
+    public String toString() {
+        return FILE_COUNT + " x read a " + FILE_SIZE + "kB file";
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileReadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java?rev=921362&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java Wed Mar 10 14:21:42 2010
@@ -0,0 +1,77 @@
+/*
+ * 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.jackrabbit.benchmark;
+
+import java.util.Calendar;
+
+import javax.jcr.Binary;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
+
+public class SmallFileWriteTest extends PerformanceTest {
+
+    private static final int FILE_COUNT = 100;
+
+    private static final int FILE_SIZE = 10;
+
+    private Session session;
+
+    private Node root;
+
+    public void beforeSuite() throws RepositoryException {
+        session = getRepository().login(getCredentials());
+    }
+
+    public void beforeTest() throws RepositoryException {
+        root = session.getRootNode().addNode(
+                "SmallFileWriteTest", NodeType.NT_FOLDER);
+        session.save();
+    }
+
+    public void runTest() throws Exception {
+        for (int i = 0; i < FILE_COUNT; i++) {
+            Node file = root.addNode("file" + i, NodeType.NT_FILE);
+            Node content = file.addNode(Node.JCR_CONTENT, NodeType.NT_RESOURCE);
+            content.setProperty(Property.JCR_MIMETYPE, "application/octet-stream");
+            content.setProperty(Property.JCR_LAST_MODIFIED, Calendar.getInstance());
+            Binary binary = session.getValueFactory().createBinary(
+                    new TestInputStream(FILE_SIZE * 1024));
+            try {
+                content.setProperty(Property.JCR_DATA, binary);
+            } finally {
+                binary.dispose();
+            }
+        }
+    }
+
+    public void afterTest() throws RepositoryException {
+        root.remove();
+        session.save();
+    }
+
+    public void afterSuite() throws RepositoryException {
+        session.logout();
+    }
+
+    public String toString() {
+        return FILE_COUNT + " x write a " + FILE_SIZE + "kB file";
+    }
+
+}

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/SmallFileWriteTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TestInputStream.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TestInputStream.java?rev=921362&view=auto
==============================================================================
--- jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TestInputStream.java (added)
+++ jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TestInputStream.java Wed Mar 10 14:21:42 2010
@@ -0,0 +1,49 @@
+package org.apache.jackrabbit.benchmark;
+
+import java.io.InputStream;
+import java.util.Random;
+
+/**
+ * An input stream that returns a given number of dummy data. The returned
+ * data is designed to be non-compressible to prevent possible compression
+ * mechanisms from affecting performance measurements.
+ */
+class TestInputStream extends InputStream {
+
+    private final int n;
+
+    private int i;
+
+    private final byte[] data = new byte[16 * 1024];
+
+    public TestInputStream(int length) {
+        n = length;
+        i = 0;
+
+        new Random().nextBytes(data);
+    }
+
+    @Override
+    public int read() {
+        if (i < n) {
+            return data[i++ % data.length];
+        } else {
+            return -1;
+        }
+    }
+
+    @Override
+    public int read(byte[] b, int off, int len) {
+        if (i < n) {
+            int dataOff = i % data.length;
+            int dataLen = Math.min(len, data.length - dataOff);
+            System.arraycopy(data, dataOff, b, off, dataLen);
+            i += dataLen;
+            return dataLen;
+        } else {
+            return -1;
+        }
+    }
+
+
+}
\ No newline at end of file

Propchange: jackrabbit/commons/jcr-benchmark/trunk/src/main/java/org/apache/jackrabbit/benchmark/TestInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native