Mercurial > hg > Members > tatsuki > jungle-bench
changeset 25:69dca2ab1783
add mongoBenchMark script
author | tatsuki |
---|---|
date | Mon, 04 May 2015 00:20:18 +0900 |
parents | e2f418db92e9 |
children | 96fcae37c62a |
files | mongoBenchMark/find.js mongoBenchMark/insertData.js mongoBenchMark/mongoBenchMark.sh src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/PerformanceComparisonJungleMongo.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/readMongoThread.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/ReadJungleThread.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java |
diffstat | 7 files changed, 79 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mongoBenchMark/find.js Mon May 04 00:20:18 2015 +0900 @@ -0,0 +1,8 @@ +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"}); +} +var date_obj = new Date(); +print(date_obj.getTime() - milliseconds)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mongoBenchMark/insertData.js Mon May 04 00:20:18 2015 +0900 @@ -0,0 +1,53 @@ +use tatsuki +db.collection.drop(); +for (var i = 1; i<= 100 ; 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});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mongoBenchMark/mongoBenchMark.sh Mon May 04 00:20:18 2015 +0900 @@ -0,0 +1,2 @@ +mongo --quiet < insertData.js +mongo --quiet < find.js
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/PerformanceComparisonJungleMongo.java Sat May 02 04:56:52 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/PerformanceComparisonJungleMongo.java Mon May 04 00:20:18 2015 +0900 @@ -19,7 +19,7 @@ */ public class PerformanceComparisonJungleMongo { - public static void main(String args[]) throws InterruptedException, IOException, SAXException, ParserConfigurationException { + 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"); @@ -28,14 +28,12 @@ else if (args[0].equals("jungle")) PerformanceCheckJungle(); System.out.println("end"); - - } private static void PerformanceCheckJungle() throws ParserConfigurationException, IOException, SAXException, InterruptedException { File file = new File("./time/jungleBenchMark"); PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); - for (int count = 100; count <= 1000; count = 100 + count) { + 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); @@ -49,11 +47,12 @@ pw.close(); } + private static void PerformanceCheckMongo() throws InterruptedException, IOException { MongoClient client = new MongoClient("localhost", 27017); File file = new File("./time/mongoBenchMark"); PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); - for (int count = 100; count <= 1000; count = 100 + count) { + for (int count = 100; count <= 1000; count = 50 + count) { client.setWriteConcern(WriteConcern.JOURNALED); client.dropDatabase("mydb"); MongoDatabase database = client.getDatabase("mydb"); @@ -103,3 +102,4 @@ pw.close(); } } +
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/readMongoThread.java Sat May 02 04:56:52 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/readMongoThread.java Mon May 04 00:20:18 2015 +0900 @@ -31,8 +31,9 @@ @Override public void run() { + Document query = new Document("Personid", "p:3"); while (loop) { - MongoCursor<Document> result = mongoDB.find(new Document("Personid", "p:3")).iterator(); + MongoCursor<Document> result = mongoDB.find(query).iterator(); if (result.hasNext()) findCount++; }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/ReadJungleThread.java Sat May 02 04:56:52 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/ReadJungleThread.java Mon May 04 00:20:18 2015 +0900 @@ -1,6 +1,5 @@ package jp.ac.u_ryukyu.ie.cr.tatsuki.xml; -import java.util.Random; import jp.ac.u_ryukyu.cr.ie.tatsuki.xmlTestBbs.JuGrix; @@ -31,13 +30,9 @@ @Override public void run() { while (loop) { - - findCount++; - boolean account = jugrix.isActive("p:" + 100,"v:1"); + boolean account = jugrix.isActive("p:" + 20,"v:1"); if (account) - successCount++; - else - faildCount++; + findCount++; } } }
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Sat May 02 04:56:52 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Mon May 04 00:20:18 2015 +0900 @@ -1,20 +1,14 @@ package jp.ac.u_ryukyu.ie.cr.tatsuki.xml; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.nio.ByteBuffer; -import java.util.Random; - -import javax.xml.parsers.ParserConfigurationException; - -import org.xml.sax.SAXException; - import jp.ac.u_ryukyu.cr.ie.tatsuki.xmlTestBbs.JuGrix; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; +import org.xml.sax.SAXException; + +import javax.xml.parsers.ParserConfigurationException; +import java.io.*; +import java.nio.ByteBuffer; +import java.util.Random; public class TransactionPerSecondMeasurement { @@ -39,7 +33,7 @@ Runtime rt = Runtime.getRuntime(); int cpuNum = rt.availableProcessors(); - File file = new File("./time/newTransactionReadAndWrite"); + File file = new File("./time/ReadAndWrite"); PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file))); for (int THREAD_COUNT = 1; THREAD_COUNT <= cpuNum; THREAD_COUNT++) {