jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1539281 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: BenchmarkRunner.java ConcurrentTraversalTest.java ReadDeepTreeTest.java
Date Wed, 06 Nov 2013 09:12:28 GMT
Author: angela
Date: Wed Nov  6 09:12:28 2013
New Revision: 1539281

URL: http://svn.apache.org/r1539281
Log:
OAK-527: add benchmark that reads random items and traverses each node to maxlevel = 10

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentTraversalTest.java
      - copied, changed from r1539032, jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadDeepTreeTest.java
Modified:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/BenchmarkRunner.java
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.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=1539281&r1=1539280&r2=1539281&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
Wed Nov  6 09:12:28 2013
@@ -153,6 +153,11 @@ public class BenchmarkRunner {
                     itemsToRead.value(options),
                     report.value(options),
                     randomUser.value(options)),
+            new ConcurrentTraversalTest(
+                    runAsAdmin.value(options),
+                    itemsToRead.value(options),
+                    report.value(options),
+                    randomUser.value(options)),
             ReadManyTest.linear("LinearReadEmpty", 1, ReadManyTest.EMPTY),
             ReadManyTest.linear("LinearReadFiles", 1, ReadManyTest.FILES),
             ReadManyTest.linear("LinearReadNodes", 1, ReadManyTest.NODES),

Copied: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentTraversalTest.java
(from r1539032, jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadDeepTreeTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentTraversalTest.java?p2=jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentTraversalTest.java&p1=jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadDeepTreeTest.java&r1=1539032&r2=1539281&rev=1539281&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadDeepTreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentTraversalTest.java
Wed Nov  6 09:12:28 2013
@@ -16,13 +16,85 @@
  */
 package org.apache.jackrabbit.oak.benchmark;
 
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.util.TraversingItemVisitor;
+
 /**
- * Concurrently reads random items from the deep tree.
+ * Concurrently reads random items from the deep tree and traverses the the
+ * subtree until {@code MAX_LEVEL} is reached, which is currently set to 10.
  */
-public class ConcurrentReadDeepTreeTest extends ReadDeepTreeTest {
+public class ConcurrentTraversalTest extends ManyUserReadTest {
+
+    /* number of levels to traverse */
+    private static final int MAX_LEVEL = 10;
+
+    protected ConcurrentTraversalTest(boolean runAsAdmin, int itemsToRead, boolean doReport,
boolean randomUser) {
+        super(runAsAdmin, itemsToRead, doReport, randomUser);
+    }
+
+    @Override
+    protected void runTest() throws Exception {
+        traverse(testSession, itemsToRead);
+    }
 
-    public ConcurrentReadDeepTreeTest(boolean runAsAdmin, int itemsToRead, boolean doReport)
{
-        super(runAsAdmin, itemsToRead, doReport);
+    protected void traverse(Session testSession, int cnt) throws RepositoryException {
+        boolean logout = false;
+        if (testSession == null) {
+            testSession = getTestSession();
+            logout = true;
+        }
+        try {
+            int nodeCnt = 0;
+            int propertyCnt = 0;
+            int noAccess = 0;
+            int size = allPaths.size();
+            long start = System.currentTimeMillis();
+            for (int i = 0; i < cnt; i++) {
+                double rand = size * Math.random();
+                int index = (int) Math.floor(rand);
+                String path = allPaths.get(index);
+                if (testSession.itemExists(path)) {
+                    Item item = testSession.getItem(path);
+                    Visitor visitor = new Visitor();
+                    item.accept(visitor);
+                    nodeCnt += visitor.nodeCnt;
+                    propertyCnt += visitor.propertyCnt;
+                } else {
+                    noAccess++;
+                }
+            }
+            long end = System.currentTimeMillis();
+            if (doReport) {
+                System.out.println("Session " + testSession.getUserID() + " reading " + (cnt-noAccess)
+ " (Nodes: "+ nodeCnt +"; Properties: "+propertyCnt+") completed in " + (end - start));
+            }
+        } finally {
+            if (logout) {
+                logout(testSession);
+            }
+        }
     }
 
+    private final class Visitor extends TraversingItemVisitor.Default {
+
+        private long propertyCnt;
+        private long nodeCnt;
+
+        public Visitor() {
+            super(false, MAX_LEVEL);
+        }
+
+        @Override
+        protected void entering(Property property, int level) {
+            propertyCnt++;
+        }
+
+        @Override
+        protected void entering(Node node, int level) {
+            nodeCnt++;
+        }
+    }
 }

Modified: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java?rev=1539281&r1=1539280&r2=1539281&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
(original)
+++ jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ReadDeepTreeTest.java
Wed Nov  6 09:12:28 2013
@@ -43,7 +43,7 @@ public class ReadDeepTreeTest extends Ab
     protected Session adminSession;
     protected Node testRoot;
 
-    private Session testSession;
+    protected Session testSession;
 
     protected List<String> allPaths = new ArrayList<String>();
 



Mime
View raw message