Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 71344 invoked from network); 10 Mar 2010 14:22:38 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Mar 2010 14:22:38 -0000 Received: (qmail 7758 invoked by uid 500); 10 Mar 2010 14:22:07 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 7707 invoked by uid 500); 10 Mar 2010 14:22:07 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 7700 invoked by uid 99); 10 Mar 2010 14:22:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Mar 2010 14:22:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 10 Mar 2010 14:22:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8507F2388906; Wed, 10 Mar 2010 14:21:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r921362 - in /jackrabbit/commons/jcr-benchmark/trunk: ./ src/main/java/org/apache/jackrabbit/benchmark/ Date: Wed, 10 Mar 2010 14:21:43 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100310142143.8507F2388906@eris.apache.org> 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 @@ org.apache.jackrabbit parent - 3 + 5 jackrabbit-jcr-benchmark - 1.6-SNAPSHOT + 2.0-SNAPSHOT Jackrabbit JCR Benchmarks JCR Benchmark is a suite of performance and scalability tests for @@ -51,23 +51,40 @@ javax.jcr jcr - 1.0 + 2.0 - junit - junit - 3.8.1 + org.apache.commons + commons-math + 2.0 - org.slf4j - slf4j-api - 1.5.3 + org.apache.jackrabbit + jackrabbit-jcr-tests + 2.1-SNAPSHOT org.apache.jackrabbit - jackrabbit-jcr-tests - 1.5.0 + jackrabbit-core + 2.1-SNAPSHOT + + + org.slf4j + slf4j-nop + 1.5.8 + + + + maven-compiler-plugin + + 1.5 + 1.5 + + + + + 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; -/** LoginTest... */ -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). - *

- * 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