changeset 199:5aad7dbb390e

add benchMark
author tatsuki
date Thu, 07 May 2015 08:16:57 +0900
parents a7ec6978e725
children e746d21e83ff
files benchmark/find.js benchmark/insert.js src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/benchMark/JungleBenchMark.java
diffstat 3 files changed, 83 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/benchmark/find.js	Thu May 07 08:16:57 2015 +0900
@@ -0,0 +1,16 @@
+function findDataLoop () {
+var date_obj = new Date();
+var milliseconds = date_obj.getTime();
+for (var i = 1; i<= 50000; i++) {
+  var personData = db.person1.find({PersonId:"p:9"}).next();
+  var roleId = personData.roleId
+}
+date_obj = new Date();
+print(date_obj.getTime() - milliseconds)
+}
+
+function findData () {
+  var personVer = db.config.find({configVer:"v:1"}).next().PersonVer;
+  var personCollection = db.getCollection(personVer); 
+  db.person1.find({PersonId:"p:9"}).next();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/benchmark/insert.js	Thu May 07 08:16:57 2015 +0900
@@ -0,0 +1,13 @@
+function insertData(personCount) {
+db.person1.drop();
+for (var i = 1; i<= personCount  ; i++) {
+
+    var user = {
+   
+    PersonId: "p:" + String(i),
+    roleRefIds:"r:" + String(i)}
+  db.person1.insert(user);
+}
+
+db.person1.createIndex({PersonId:1});
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/jungle/benchMark/JungleBenchMark.java	Thu May 07 08:16:57 2015 +0900
@@ -0,0 +1,54 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.benchMark;
+
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser;
+
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+
+
+/**
+ * Created by e115731 on 15/05/07.
+ */
+public class JungleBenchMark {
+    public static void main(String args[]) {
+        Jungle jungle = new DefaultJungle(null, "hogehoge", new DefaultTreeEditor(new DefaultTraverser()));
+        jungle.createNewTree("tree");
+        JungleTree tree = jungle.getTreeByName("tree");
+        JungleTreeEditor editor = tree.getTreeEditor();
+        NodePath path = new DefaultNodePath().add(0);
+        for (int count = 1; count <= 10; count++) {
+            for (int personCount = 0; personCount < 1000 * count; personCount++) {
+                editor = editor.replaceNewRootNode().b();
+                editor = editor.putAttribute(path, "personId", ByteBuffer.wrap(("p:" + personCount).getBytes())).b();
+                editor = editor.putAttribute(path, "roleId", ByteBuffer.wrap(("r:" + personCount).getBytes())).b();
+            }
+            editor.success();
+            long t1 = System.currentTimeMillis();
+            for (int findCount = 0; findCount < 50000; ) {
+                InterfaceTraverser traverser = tree.getTraverser(true);
+                Iterator<TreeNode> it = traverser.find(null, "personId", "p:100");
+                if (it.hasNext()) {
+                    TreeNode targetNode = it.next();
+                    String targetRoleId = targetNode.getAttributes().getString("roleId");
+                    if (targetRoleId.equals("r:100"))
+                        findCount++;
+                } else {
+                    System.out.println("find miss");
+                    System.exit(1);
+                }
+            }
+            long t2 = System.currentTimeMillis();
+            System.out.println("time = " + (t2 - t1));
+        }
+
+    }
+}