jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1533004 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: AbstractTest.java BenchmarkRunner.java CreateManyNodesTest.java
Date Thu, 17 Oct 2013 08:19:08 GMT
Author: thomasm
Date: Thu Oct 17 08:19:07 2013
New Revision: 1533004

URL: http://svn.apache.org/r1533004
Log:
OAK-641: Improved benchmark tooling - new CreateManyNodesTest

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateManyNodesTest.java
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/BenchmarkRunner.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=1533004&r1=1533003&r2=1533004&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
Thu Oct 17 08:19:07 2013
@@ -21,6 +21,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Random;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.jcr.Credentials;
 import javax.jcr.GuestCredentials;
@@ -47,6 +48,15 @@ abstract class AbstractTest extends Benc
      */
     static final String TEST_ID = Integer.toHexString(new Random().nextInt());
     
+    static AtomicInteger counter = new AtomicInteger();
+    
+    /**
+     * A node name that is guarantee to be unique within the current JVM.
+     */
+    static String nextNodeName() {
+        return "n" + Integer.toHexString(counter.getAndIncrement());
+    }
+    
     private static final Credentials CREDENTIALS = new SimpleCredentials("admin", "admin".toCharArray());
 
     private static final long WARMUP = TimeUnit.SECONDS.toMillis(Long.getLong("warmup", 5));

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1533004&r1=1533003&r2=1533004&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
Thu Oct 17 08:19:07 2013
@@ -108,6 +108,7 @@ public class BenchmarkRunner {
             new DescendantSearchTest(),
             new SQL2DescendantSearchTest(),
             new CreateManyChildNodesTest(),
+            new CreateManyNodesTest(),
             new UpdateManyChildNodesTest(),
             new TransientManyChildNodesTest(),
             new WikipediaImport(wikipedia.value(options)),

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateManyNodesTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateManyNodesTest.java?rev=1533004&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateManyNodesTest.java
(added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateManyNodesTest.java
Thu Oct 17 08:19:07 2013
@@ -0,0 +1,72 @@
+/*
+ * 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.oak.benchmark;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+/**
+ * Test for measuring the performance of creating a nodes (with a low fanout,
+ * that is, with few child nodes for each node).
+ */
+public class CreateManyNodesTest extends AbstractTest {
+    
+    protected static final String ROOT_NODE_NAME = "many" + TEST_ID;
+
+    private static final int FANOUT = 5;
+    private static final int LEVELS = 4;
+    private static final int SAVE_EVERY = 150;
+
+    private Session session;
+    private Node testRootNode;
+    private int nodeCount;
+
+    @Override
+    public void beforeSuite() throws RepositoryException {
+        session = loginWriter();
+        testRootNode = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:unstructured");
+    }
+    
+    @Override
+    public void afterSuite() throws RepositoryException {
+        testRootNode.remove();
+    }
+
+    @Override
+    public void runTest() throws Exception {
+        nodeCount = 0;
+        nodeCount++;
+        Node node = testRootNode.addNode(nextNodeName(), "nt:unstructured");
+        addChildNodes(node, LEVELS);
+        session.save();
+    }
+    
+    private void addChildNodes(Node parent, int level) throws Exception {
+        for (int i = 0; i < FANOUT; i++) {
+            nodeCount++;
+            Node n = parent.addNode("l" + level + "n" + i, "nt:unstructured");
+            if (nodeCount % SAVE_EVERY == 0) {
+                n.getSession().save();
+            }
+            if (level > 0) {
+                addChildNodes(n, level - 1);
+            }
+        }
+    }
+
+}



Mime
View raw message