jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r1166065 - in /jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk: index/PrefixIndexTest.java large/CreateNodesTraverseTest.java large/LargeNodeTest.java
Date Wed, 07 Sep 2011 08:52:15 GMT
Author: thomasm
Date: Wed Sep  7 08:52:15 2011
New Revision: 1166065

URL: http://svn.apache.org/viewvc?rev=1166065&view=rev
Log:
Improved tests.

Modified:
    jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java
    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/index/PrefixIndexTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java?rev=1166065&r1=1166064&r2=1166065&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java
(original)
+++ jackrabbit/sandbox/microkernel/src/test/java/org/apache/jackrabbit/mk/index/PrefixIndexTest.java
Wed Sep  7 08:52:15 2011
@@ -27,8 +27,8 @@ import org.apache.jackrabbit.mk.api.Micr
 public class PrefixIndexTest extends TestCase {
 
     // private static final String URL = "fs:{homeDir}/target";
-    // private static final String URL = "mem:fs:target/temp;clean";
-    private static final String URL = "mem:;clean";
+    // private static final String URL = "mem:fs:target/temp";
+    private static final String URL = "mem:";
 
     public void test() {
         test(URL);

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=1166065&r1=1166064&r2=1166065&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
Wed Sep  7 08:52:15 2011
@@ -22,22 +22,24 @@ import org.apache.jackrabbit.mk.api.Micr
  */
 public class CreateNodesTraverseTest extends TestCase {
 
+    // -Xmx512m -Dmk.fastDb=true
+
     private static final String URL = "mem:;clean";
-    // created 200000 nodes in 3 seconds (61633 nodes/sec)
-    // read 200000 nodes in 0 seconds (212539 nodes/sec)
+    // created 200000 nodes in 3 seconds (62617 nodes/sec)
+    // read 200000 nodes in 0 seconds (213219 nodes/sec)
 
     // private static final String URL = "fs:target/temp;clean";
-    // created 200000 nodes in 22 seconds (8837 nodes/sec)
-    // created 1031180 nodes in 714 seconds (1442 nodes/sec)
+    // created 200000 nodes in 20 seconds (9783 nodes/sec)
+    // read 200000 nodes in 73 seconds (2733 nodes/sec)
 
     // private static final String URL = "mem:fs:target/temp;clean";
 
-    // -Xmx512m -Dmk.fastDb=true
-    // private int totalCount = 100000;
+    // private int totalCount = 200000;
 
     private int totalCount = 200;
 
     private int width = 30, count;
+    private long start, last;
     private MicroKernel mk;
     private String head;
 
@@ -67,7 +69,7 @@ public class CreateNodesTraverseTest ext
         log("depth: " + depth);
         head = mk.commit("/", "+\"test\":{}", head, "");
         long time;
-        time = System.currentTimeMillis();
+        start = time = System.currentTimeMillis();
         count = 0;
         createNodes("test", depth);
         time = System.currentTimeMillis() - time;
@@ -75,7 +77,7 @@ public class CreateNodesTraverseTest ext
                 " seconds (" + (count * 1000 / time) + " nodes/sec)");
 
         for (int i = 0; i < 2; i++) {
-            time = System.currentTimeMillis();
+            start = time = System.currentTimeMillis();
             count = 0;
             traverse("test", depth);
             time = System.currentTimeMillis() - time;
@@ -96,8 +98,12 @@ public class CreateNodesTraverseTest ext
             }
             String p = parent + "/node" + depth + i;
             buff.append("+ \"" + p + "\": {\"data\":\"Hello World " + count++ + "\"}\n");
-            if (count % 200000 == 0) {
-                log(count + " nodes");
+            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, "");
@@ -123,8 +129,12 @@ public class CreateNodesTraverseTest ext
             }
             mk.getNodes("/" + p, head);
             count++;
-            if (count % 200000 == 0) {
-                log(count + " nodes");
+            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);

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=1166065&r1=1166064&r2=1166065&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
Wed Sep  7 08:52:15 2011
@@ -28,11 +28,10 @@ import org.apache.jackrabbit.mk.mem.Node
 public class LargeNodeTest extends TestCase {
 
     // private static final String URL = "fs:{homeDir};clean";
-    // private static final String URL = "mem:;clean";
-    private static final String URL = "mem:fs:target/temp;clean";
+    private static final String URL = "mem:;clean";
+    // private static final String URL = "mem:fs:target/temp;clean";
 
     private MicroKernel mk;
-
     private String head;
 
     public void setUp() throws Exception {
@@ -45,13 +44,92 @@ public class LargeNodeTest extends TestC
         mk.dispose();
     }
 
+    public void testVeryLargeNodeList() {
+        if (URL.startsWith("mem:")) {
+            int max = 2000;
+            assertEquals("{\":childNodeCount\":0}", mk.getNodes("/:root/head/config", head));
+            head = mk.commit("/:root/head/config", "^ \"maxMemoryChildren\":" + max, head,
"");
+            assertEquals("{\"maxMemoryChildren\":"+max+",\":childNodeCount\":0}", mk.getNodes("/:root/head/config",
head));
+        }
+        head = mk.commit("/", "+ \"t\": {}", head, "");
+
+        // added 100000 nodes (1438 nodes/second)
+        // added 100000 nodes (18611 nodes/second)
+        int count = 5000;
+        // int count = 1000000;
+        long start = System.currentTimeMillis(), last = start;
+        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)");
+                }
+            }
+            buff.append("+ \"t/" + i + "\": {\"x\":" + i + "}\n");
+            if (i % 1000 == 0) {
+                head = mk.commit("/", buff.toString(), head, "");
+                buff.setLength(0);
+            }
+        }
+        long time = System.currentTimeMillis() - start + 1;
+        log("added " + count + " nodes (" + (count * 1000 / time) + " nodes/second)");
+        if (buff.length() > 0) {
+            head = mk.commit("/", buff.toString(), head, "");
+        }
+        assertEquals("{\":childNodeCount\":"+count+"}", mk.getNodes("/t", head, 1, 0, 0));
+    }
+
+    private static void log(String s) {
+        // System.out.println(s);
+    }
+
+    public void testLargeNodeList() {
+        if (URL.startsWith("fs:")) {
+            return;
+        }
+        assertEquals("{\":childNodeCount\":0}", mk.getNodes("/:root/head/config", head));
+        head = mk.commit("/:root/head/config", "^ \"maxMemoryChildren\": 10", head, "");
+        assertEquals("{\"maxMemoryChildren\":10,\":childNodeCount\":0}", mk.getNodes("/:root/head/config",
head));
+        for (int i = 0; i < 100; i++) {
+            head = mk.commit("/", "+ \"t" + i + "\": {\"x\":" + i + "}", head, "");
+        }
+        assertEquals("{\":childNodeCount\":101,\"test\":{\":childNodeCount\":3}," +
+                "\"t0\":{\"x\":0,\":childNodeCount\":0}," +
+                "\"t1\":{\"x\":1,\":childNodeCount\":0}," +
+                "\"t2\":{\"x\":2,\":childNodeCount\":0}," +
+                "\"t3\":{\"x\":3,\":childNodeCount\":0}," +
+                "\"t4\":{\"x\":4,\":childNodeCount\":0}," +
+                "\"t5\":{\"x\":5,\":childNodeCount\":0}," +
+                "\"t6\":{\"x\":6,\":childNodeCount\":0}," +
+                "\"t7\":{\"x\":7,\":childNodeCount\":0}," +
+                "\"t8\":{\"x\":8,\":childNodeCount\":0}}", mk.getNodes("/", head, 1, 0, -1));
+        assertEquals("{\":childNodeCount\":101," +
+                "\"t0\":{\"x\":0,\":childNodeCount\":0}," +
+                "\"t1\":{\"x\":1,\":childNodeCount\":0}}", mk.getNodes("/", head, 1, 1, 2));
+        assertEquals("{\":childNodeCount\":101," +
+                "\"t9\":{\"x\":9,\":childNodeCount\":0}," +
+                "\"t10\":{\"x\":10,\":childNodeCount\":0}}", mk.getNodes("/", head, 1, 10,
2));
+        assertEquals("{\":childNodeCount\":101," +
+                "\"t19\":{\"x\":19,\":childNodeCount\":0}," +
+                "\"t20\":{\"x\":20,\":childNodeCount\":0}}", mk.getNodes("/", head, 1, 20,
2));
+        assertEquals("{\":childNodeCount\":101," +
+                "\"t39\":{\"x\":39,\":childNodeCount\":0}," +
+                "\"t40\":{\"x\":40,\":childNodeCount\":0}}", mk.getNodes("/", head, 1, 40,
2));
+        assertEquals("{\":childNodeCount\":101," +
+                "\"t89\":{\"x\":89,\":childNodeCount\":0}," +
+                "\"t90\":{\"x\":90,\":childNodeCount\":0}}", mk.getNodes("/", head, 1, 90,
2));
+    }
+
     public void testOffsetLimit() {
-        assertEquals("{a,b,c}", getNode("/test", -1, 0, -1));
-        assertEquals("{b,c}", getNode("/test", -1, 1, -1));
-        assertEquals("{c}", getNode("/test", -1, 2, -1));
-        assertEquals("{a}", getNode("/test", -1, 0, 1));
-        assertEquals("{a,b}", getNode("/test", -1, 0, 2));
-        assertEquals("{b}", getNode("/test", -1, 1, 1));
+        assertEquals("{a,b,c}", getNode("/test", 0, 0, -1));
+        assertEquals("{b,c}", getNode("/test", 0, 1, -1));
+        assertEquals("{c}", getNode("/test", 0, 2, -1));
+        assertEquals("{a}", getNode("/test", 0, 0, 1));
+        assertEquals("{a,b}", getNode("/test", 0, 0, 2));
+        assertEquals("{b}", getNode("/test", 0, 1, 1));
     }
 
     private void commit(String root, String diff) {
@@ -74,14 +152,15 @@ public class LargeNodeTest extends TestC
         NodeImpl n = new NodeImpl(map, 0);
         assertEquals("n0={}", n.asString());
         n.setId(255);
-        assertEquals("n255={}", n.asString());
+        assertEquals("nff={}", n.asString());
         n.setPath("/test");
-        assertEquals("n255={}/* /test */", n.toString());
+        assertEquals("nff={}/* /test */", n.toString());
         n = n.createClone(10);
         assertEquals("n0={}", n.asString());
         NodeImpl a = new NodeImpl(map, 0);
         NodeImpl b = new NodeImpl(map, 0);
         NodeImpl c = new NodeImpl(map, 0);
+        NodeImpl d = new NodeImpl(map, 0);
         n = n.cloneAndAddChildNode("a", false, null, a, 11);
         n = n.cloneAndSetProperty("x", "1", 12);
         n.setId(3);
@@ -92,10 +171,20 @@ public class LargeNodeTest extends TestC
         n = new NodeImpl(map, 0);
         n = n.cloneAndAddChildNode("a", false, null, a, 1);
         assertEquals("n0={\"a\":n1}", n.asString());
-        n = n.cloneAndAddChildNode("b", false, null, b, 1);
+        n = n.cloneAndAddChildNode("b", false, null, b, 2);
         assertEquals("n0={\"a\":n1,\"b\":n2}", n.asString());
-        n = n.cloneAndAddChildNode("c", false, null, c, 1);
+        n = n.cloneAndAddChildNode("c", false, null, c, 3);
         assertEquals("n0={\"a\":n1,\"b\":n2,\"c\":n3}", n.asString());
+        n = n.cloneAndAddChildNode("d", false, null, d, 4);
+        assertEquals("n0={\":children\":n4,\":names\":\"63\",\":children\":n6,\":names\":\"64\",\":childCount\":4}",
+                n.asString());
+        n2 = NodeImpl.fromString(map, n.asString());
+        assertEquals("n0={\":children\":n4,\":names\":\"63\",\":children\":n6,\":names\":\"64\",\":childCount\":4}",
+                n2.asString());
+        assertTrue(n2.exists("a"));
+        assertTrue(n2.exists("b"));
+        assertTrue(n2.exists("c"));
+        assertTrue(n2.exists("d"));
 
     }
 



Mime
View raw message