changeset 28:2ac12de0aaeb default tip

mongo BenchMark change
author tatsuki
date Tue, 05 May 2015 01:19:04 +0900
parents ea29bd59d9c8
children
files mongoBenchMark/find.js mongoBenchMark/insert.js
diffstat 2 files changed, 75 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mongoBenchMark/find.js	Mon May 04 15:38:54 2015 +0900
+++ b/mongoBenchMark/find.js	Tue May 05 01:19:04 2015 +0900
@@ -1,8 +1,13 @@
-use tatsuki
-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"});
+function findDataLoop () {
+  for (var i = 1; i<= 50000; i++) {
+    var personVer = db.config.find({configVer:"v:1"}).next().PersonVer;
+    var personCollection = db.getCollection(personVer); 
+    db.person1.find({PersonId:"p:9"}).next();
+  }
 }
-var 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();
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mongoBenchMark/insert.js	Tue May 05 01:19:04 2015 +0900
@@ -0,0 +1,63 @@
+function insertData(personCount) {
+db.person1.drop();
+db.config.drop();
+for (var i = 1; i<= personCount  ; 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.person1.insert(user);
+}
+
+var config = {
+  configVer : "v:1",
+  PersonVer: "person1",
+  OrgVer: "org1",
+  RoleVer:"Role1"
+}
+db.person1.createIndex({PersonId:1});
+db.config.insert(config);
+db.config.createIndex({configVer:1});
+}
\ No newline at end of file