jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1209566 - in /jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large: CreateNodesTraverseTest.java LargeNodeTest.java
Date Fri, 02 Dec 2011 16:29:56 GMT
Author: thomasm
Date: Fri Dec  2 16:29:56 2011
New Revision: 1209566

URL: http://svn.apache.org/viewvc?rev=1209566&view=rev
Log:
Using the StopWatch and NodeCreator tools

Modified:
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/CreateNodesTraverseTest.java
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/CreateNodesTraverseTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/CreateNodesTraverseTest.java?rev=1209566&r1=1209565&r2=1209566&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/CreateNodesTraverseTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/CreateNodesTraverseTest.java
Fri Dec  2 16:29:56 2011
@@ -14,6 +14,7 @@
 package org.apache.jackrabbit.mk.large;
 
 import org.apache.jackrabbit.mk.MultiMkTestBase;
+import org.apache.jackrabbit.mk.util.NodeCreator;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -26,118 +27,20 @@ public class CreateNodesTraverseTest ext
 
     // -Xmx512m -Dmk.fastDb=true
 
-    // private int totalCount = 200000;
-
     private int totalCount = 200;
 
-    private int width = 30, count;
-    private long start, last;
-    private String head;
+    // private int totalCount = 2000000;
 
     public CreateNodesTraverseTest(String url) {
         super(url);
     }
 
     @Test
-    public void test1() throws Exception {
-        // Profiler p = new Profiler();
-        // p.interval = 2;
-        // p.startCollecting();
-        // test();
-        // System.out.println(p.getTop(5));
-    }
-
-    @Test
     public void test() throws Exception {
-        head = mk.getHeadRevision();
-
-        int depth = (int) Math.ceil(Math.log(totalCount) / Math.log(width));
-        log("depth: " + depth);
-        head = mk.commit("/", "+\"test\":{}", head, "");
-        long time;
-        start = time = System.currentTimeMillis();
-        count = 0;
-        createNodes("test", depth);
-        time = System.currentTimeMillis() - time;
-        if (time == 0) {
-            log("Cannot time execution of test due to insufficient timer resolution");
-        } else {
-            log("created " + count + " nodes in " + (time / 1000) +
-                    " seconds (" + (count * 1000 / time) + " nodes/sec)");
-        }
-
-        for (int i = 0; i < 2; i++) {
-            start = time = System.currentTimeMillis();
-            count = 0;
-            traverse("test", depth);
-            time = System.currentTimeMillis() - time;
-            if (time == 0) {
-                log("Cannot time execution of test due to insufficient timer resolution");
-            } else {
-                log("read " + count + " nodes in " + (time / 1000) +
-                        " seconds (" + (count * 1000 / time) + " nodes/sec)");
-            }
-        }
-
-    }
-
-    private void createNodes(String parent, int depth) {
-        if (count >= totalCount) {
-            return;
-        }
-        StringBuilder buff = new StringBuilder();
-        for (int i = 0; i < width; i++) {
-            if (count >= totalCount && depth == 0) {
-                break;
-            }
-            String p = parent + "/node" + depth + i;
-            buff.append("+ \"" + p + "\": {\"data\":\"Hello World " + count++ + "\"}\n");
-            if (count % 1000 == 0) {
-                long now = System.currentTimeMillis();
-                if (now - last > 1000) {
-                    last = now;
-                    log(count + " nodes (" + (count * 1000 / (now - start)) + " op/s)");
-                }
-            }
-        }
-        head = mk.commit("/", buff.toString(), head, "");
-        if (depth > 0) {
-            for (int i = 0; i < width; i++) {
-                String p = parent + "/node" + depth + i;
-                createNodes(p, depth - 1);
-            }
-        }
-    }
-
-    private void traverse(String parent, int depth) throws Exception {
-        if (count >= totalCount) {
-            return;
-        }
-        for (int i = 0; i < width; i++) {
-            if (count >= totalCount && depth == 0) {
-                break;
-            }
-            String p = parent + "/node" + depth + i;
-            if (!mk.nodeExists("/" + p, head)) {
-                break;
-            }
-            mk.getNodes("/" + p, head);
-            count++;
-            if (count % 1000 == 0) {
-                long now = System.currentTimeMillis();
-                if (now - last > 1000) {
-                    last = now;
-                    log(count + " nodes (" + (count * 1000 / (now - start)) + " op/s)");
-                }
-            }
-            if (depth > 0) {
-                traverse(p, depth - 1);
-            }
-        }
-    }
-
-    private void log(String s) {
-        // System.out.println(url + " " + s);
+        NodeCreator c = new NodeCreator(mk);
+        c.setTotalCount(totalCount);
+        c.create();
+        c.traverse();
     }
 
 }

Modified: jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java?rev=1209566&r1=1209565&r2=1209566&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/large/LargeNodeTest.java
Fri Dec  2 16:29:56 2011
@@ -20,6 +20,7 @@ import junit.framework.Assert;
 import org.apache.jackrabbit.mk.MultiMkTestBase;
 import org.apache.jackrabbit.mk.mem.NodeImpl;
 import org.apache.jackrabbit.mk.mem.NodeMap;
+import org.apache.jackrabbit.mk.util.StopWatch;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -72,16 +73,11 @@ public class LargeNodeTest extends Multi
         // added 100000 nodes (18611 nodes/second)
         int count = 5000;
         // int count = 1000000;
-        long start = System.currentTimeMillis(), last = start;
+        StopWatch timer = new StopWatch();
         StringBuilder buff = new StringBuilder();
         for (int i = 0; i < count; i++) {
-            if (i % 100 == 0) {
-                long n = System.currentTimeMillis();
-                if (n > last + 1000) {
-                    last = n;
-                    long time = System.currentTimeMillis() - start + 1;
-                    log("added " + i + " nodes (" + (i * 1000 / time) + " nodes/second)");
-                }
+            if (i % 100 == 0 && timer.log()) {
+                log("added " + i + " nodes " + timer.operationsPerSecond(i));
             }
             buff.append("+ \"t/" + i + "\": {\"x\":" + i + "}\n");
             if (i % 1000 == 0) {
@@ -89,8 +85,7 @@ public class LargeNodeTest extends Multi
                 buff.setLength(0);
             }
         }
-        long time = System.currentTimeMillis() - start + 1;
-        log("added " + count + " nodes (" + (count * 1000 / time) + " nodes/second)");
+        log("added " + count + " nodes " + timer.operationsPerSecond(count));
         if (buff.length() > 0) {
             head = mk.commit("/", buff.toString(), head, "");
         }
@@ -103,9 +98,10 @@ public class LargeNodeTest extends Multi
 
     @Test
     public void largeNodeList() {
-        if (url.startsWith("fs:")) {
+        if (!isMemoryKernel(mk)) {
             return;
         }
+
         Assert.assertEquals("{\":childNodeCount\":0}", mk.getNodes("/:root/head/config",
head));
         head = mk.commit("/:root/head/config", "^ \"maxMemoryChildren\": 10", head, "");
         Assert.assertEquals("{\"maxMemoryChildren\":10,\":childNodeCount\":0}", mk.getNodes("/:root/head/config",
head));



Mime
View raw message