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 mr...@apache.org on 2013/03/28 11:22:00 UTC

svn commit: r1462019 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: BenchmarkRunner.java CreateNodesBenchmark.java

Author: mreutegg
Date: Thu Mar 28 10:22:00 2013
New Revision: 1462019

URL: http://svn.apache.org/r1462019
Log:
OAK-726: Implement KernelNodeState.hasChildNode()

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateNodesBenchmark.java   (with props)
Modified:
    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/BenchmarkRunner.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java?rev=1462019&r1=1462018&r2=1462019&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 Mar 28 10:22:00 2013
@@ -76,6 +76,7 @@ public class BenchmarkRunner {
             new UpdateManyChildNodesTest(),
             new TransientManyChildNodesTest(),
             new WikipediaImport(wikipedia.value(options)),
+            new CreateNodesBenchmark(),
             new ManyNodes(),
             ReadManyTest.linear("LinearReadEmpty", 1, ReadManyTest.EMPTY),
             ReadManyTest.linear("LinearReadFiles", 1, ReadManyTest.FILES),

Added: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateNodesBenchmark.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateNodesBenchmark.java?rev=1462019&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateNodesBenchmark.java (added)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateNodesBenchmark.java Thu Mar 28 10:22:00 2013
@@ -0,0 +1,85 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.jackrabbit.oak.fixture.RepositoryFixture;
+
+/**
+ * Creates approximately 100k nodes (breadth first, save every 10 nodes).
+ */
+public class CreateNodesBenchmark extends Benchmark {
+
+    @Override
+    public void run(Iterable<RepositoryFixture> fixtures) {
+        for (RepositoryFixture fixture : fixtures) {
+            if (fixture.isAvailable(1)) {
+                System.out.format("%s: Create nodes benchmark%n", fixture);
+                try {
+                    Repository[] cluster = fixture.setUpCluster(1);
+                    try {
+                        run(cluster[0]);
+                    } finally {
+                        fixture.tearDownCluster();
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    private void run(Repository repository) throws RepositoryException {
+        Session session = repository.login(
+                new SimpleCredentials("admin", "admin".toCharArray()));
+        AtomicInteger count = new AtomicInteger();
+        long time = System.currentTimeMillis();
+        createNodes(session.getRootNode(), 10, 5, count);
+        time = System.currentTimeMillis() - time;
+        System.out.format(
+                "Created %d nodes in %d seconds (%.2fms/node)%n",
+                count.get(), time / 1000, (double) time / count.get());
+    }
+
+    private void createNodes(Node n, int nodesPerLevel,
+                            int levels, AtomicInteger count)
+            throws RepositoryException {
+        levels--;
+        List<Node> nodes = new ArrayList<Node>();
+        for (int i = 0; i < nodesPerLevel; i++) {
+            nodes.add(n.addNode("folder-" + i, "nt:folder"));
+            if (count.incrementAndGet() % 1000 == 0) {
+                System.out.format("Created %d nodes so far...%n", count.get());
+            }
+        }
+        n.getSession().save();
+        if (levels > 0) {
+            for (Node child : nodes) {
+                createNodes(child, nodesPerLevel, levels, count);
+            }
+        }
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateNodesBenchmark.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/CreateNodesBenchmark.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL