changeset 26:96fcae37c62a

fix mongoBenchMark
author tatsuki
date Mon, 04 May 2015 00:38:57 +0900
parents 69dca2ab1783
children ea29bd59d9c8
files mongoBenchMark/mongoBench.js mongoBenchMark/mongoBenchMark.sh src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/PerformanceComparisonJungleMongo.java
diffstat 3 files changed, 76 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mongoBenchMark/mongoBench.js	Mon May 04 00:38:57 2015 +0900
@@ -0,0 +1,64 @@
+use tatsuki
+
+for (var j = 1; j <= 10; j++){
+db.collection.drop();
+for (var i = 1; i<= 100 * j ; i++) {
+
+    var user = {
+   
+    PersonId: "p:" + String(i),
+    type: "Person",
+    accountId: "a:26",
+    lastName: "LastName",
+    name: "name",
+    nameReading: "nameReading",
+    roleRefIds: [
+        "r:10",
+        "r:34"
+      ]
+    ,
+    parentOrganizations: {
+      type: "OrganizationMappedByRole",
+      OrganizationMappedByRole: [
+        {
+          type: "OrganizationMappedByRole",
+          organizationRefId: "o:2",
+          roleRefId: "r:10"
+        },
+        {
+          type: "OrganizationMappedByRole",
+          organizationRefId: "o:11",
+          roleRefId: "r:34"
+        }
+      ]
+    },
+    priorities: {
+      type: "PriorityMappedByRole",
+      PriorityMappedByRole: [
+        {
+          type: "PriorityMappedByRole",
+          priority: "0",
+          roleRefId: "r:10"
+        },
+        {
+          type: "PriorityMappedByRole",
+          priority: "1",
+          roleRefId: "r:34"
+        }
+      ]
+    }
+};
+
+    db.collection.insert(user);
+}
+print("insertEnd");
+db.collection.createIndex({PersonId:1});
+
+var date_obj = new Date();
+var milliseconds = date_obj.getTime();
+for (var i = 1; i<= 10000000 ; i++) {
+  var PersonId = db.collection.find({PersonId:"p:9"});
+}
+var date_obj = new Date();
+print(db.collection.count() + " " +  (date_obj.getTime() - milliseconds))
+}
--- a/mongoBenchMark/mongoBenchMark.sh	Mon May 04 00:20:18 2015 +0900
+++ b/mongoBenchMark/mongoBenchMark.sh	Mon May 04 00:38:57 2015 +0900
@@ -1,2 +1,1 @@
-mongo --quiet < insertData.js
-mongo --quiet < find.js
+mongo --quiet < mongoBench.js
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/PerformanceComparisonJungleMongo.java	Mon May 04 00:20:18 2015 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/PerformanceComparisonJungleMongo.java	Mon May 04 00:38:57 2015 +0900
@@ -5,7 +5,6 @@
 import com.mongodb.client.MongoCollection;
 import com.mongodb.client.MongoDatabase;
 import jp.ac.u_ryukyu.cr.ie.tatsuki.xmlTestBbs.JuGrix;
-import jp.ac.u_ryukyu.ie.cr.tatsuki.xml.ReadJungleThread;
 import jp.ac.u_ryukyu.ie.cr.tatsuki.xml.extendXmlTree;
 import org.bson.Document;
 import org.xml.sax.SAXException;
@@ -20,8 +19,8 @@
 public class PerformanceComparisonJungleMongo {
 
     public static void main(String args[]) throws IOException, InterruptedException, ParserConfigurationException, SAXException {
-        if (args.length < 2)
-            System.out.println("args[0] = mongo or jungle ,args[1] = personCount");
+        if (args.length < 1)
+            System.out.println("args[0] = mongo or jungle");
 
         if (args[0].equals("mongo"))
             PerformanceCheckMongo();
@@ -35,14 +34,15 @@
         PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file)));
         for (int count = 100; count <= 1000; count = 50 + count) {
             JuGrix jugrix = extendXmlTree.createJuGrix(true, count);
-            boolean account = jugrix.isActive("p:" + 100,"v:1");
-            ReadJungleThread readThread = new ReadJungleThread(jugrix);
-            readThread.start();
-            Thread.sleep(1000);
-            readThread.set(false);
-            int readCount = readThread.getFindCount();
-            pw.println(count + " = " + readCount);
-            System.out.println("findCount = " + readCount);
+
+            long t1 = System.currentTimeMillis();
+            for (int readCount = 0 ; readCount < 10000000;readCount++) {
+                boolean account = jugrix.isActive("p:" + 100, "v:1");
+            }
+            long t2 = System.currentTimeMillis();
+            long readTime = t2 - t1;
+            pw.println(count + " = " + readTime);
+            System.out.println("readTime = " + readTime);
         }
         pw.close();
     }