jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1537747 - in /jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark: BenchmarkRunner.java ConcurrentReadRandomNodeAndItsPropertiesTest.java
Date Thu, 31 Oct 2013 22:44:38 GMT
Author: angela
Date: Thu Oct 31 22:44:38 2013
New Revision: 1537747

URL: http://svn.apache.org/r1537747
Log:
OAK-527: add benchmark that reads random nodes and their properties (in contrast to the other
test that read random items)

Added:
    jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadRandomNodeAndItsPropertiesTest.java
      - copied, changed from r1537476, 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

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=1537747&r1=1537746&r2=1537747&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 31 22:44:38 2013
@@ -140,6 +140,10 @@ public class BenchmarkRunner {
                     runAsAdmin.value(options),
                     itemsToRead.value(options),
                     report.value(options)),
+            new ConcurrentReadRandomNodeAndItsPropertiesTest(
+                    runAsAdmin.value(options),
+                    itemsToRead.value(options),
+                    report.value(options)),
             new ManyUserReadTest(
                     runAsAdmin.value(options),
                     itemsToRead.value(options),

Copied: jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadRandomNodeAndItsPropertiesTest.java
(from r1537476, 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/ConcurrentReadRandomNodeAndItsPropertiesTest.java?p2=jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadRandomNodeAndItsPropertiesTest.java&p1=jackrabbit/oak/trunk/oak-run/src/main/java/org/apache/jackrabbit/oak/benchmark/ConcurrentReadDeepTreeTest.java&r1=1537476&r2=1537747&rev=1537747&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/ConcurrentReadRandomNodeAndItsPropertiesTest.java
Thu Oct 31 22:44:38 2013
@@ -16,13 +16,66 @@
  */
 package org.apache.jackrabbit.oak.benchmark;
 
+import java.util.List;
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
 /**
- * Concurrently reads random items from the deep tree.
+ * Concurrently reads random nodes and it's properties from the deep tree.
  */
-public class ConcurrentReadDeepTreeTest extends ReadDeepTreeTest {
+public class ConcurrentReadRandomNodeAndItsPropertiesTest extends ReadDeepTreeTest {
 
-    public ConcurrentReadDeepTreeTest(boolean runAsAdmin, int itemsToRead, boolean doReport)
{
+    public ConcurrentReadRandomNodeAndItsPropertiesTest(boolean runAsAdmin, int itemsToRead,
boolean doReport) {
         super(runAsAdmin, itemsToRead, doReport);
     }
 
+    protected void visitingProperty(Property property, int i) throws RepositoryException
{
+        // don't remember property paths
+    }
+
+    protected void randomRead(Session testSession, List<String> allPaths, 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);
+                    if (item.isNode()) {
+                        nodeCnt++;
+                        Node n = (Node) item;
+                        PropertyIterator it = n.getProperties();
+                        while (it.hasNext()) {
+                            Property p = it.nextProperty();
+                            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);
+            }
+        }
+    }
 }



Mime
View raw message