Mercurial > hg > Members > tatsuki > jungle-bench
comparison src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/mongo/PerformanceComparisonJungleMongo.java @ 22:306441e23b8b
add PerformanceComparisonJungleMongo
author | tatsuki |
---|---|
date | Fri, 01 May 2015 20:29:27 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
21:c8d8864714d4 | 22:306441e23b8b |
---|---|
1 package jp.ac.u_ryukyu.ie.cr.tatsuki.mongo; | |
2 | |
3 import com.mongodb.MongoClient; | |
4 import com.mongodb.WriteConcern; | |
5 import com.mongodb.client.MongoCollection; | |
6 import com.mongodb.client.MongoDatabase; | |
7 import jp.ac.u_ryukyu.cr.ie.tatsuki.xmlTestBbs.JuGrix; | |
8 import jp.ac.u_ryukyu.ie.cr.tatsuki.xml.ReadJungleThread; | |
9 import jp.ac.u_ryukyu.ie.cr.tatsuki.xml.extendXmlTree; | |
10 import org.bson.Document; | |
11 import org.xml.sax.SAXException; | |
12 | |
13 import javax.xml.parsers.ParserConfigurationException; | |
14 import java.io.IOException; | |
15 import java.util.Arrays; | |
16 | |
17 /** | |
18 * Created by e115731 on 15/05/01. | |
19 */ | |
20 public class PerformanceComparisonJungleMongo { | |
21 | |
22 public static void main(String args[]) throws InterruptedException, IOException, SAXException, ParserConfigurationException { | |
23 if (args.length < 2) | |
24 System.out.println("args[0] = mongo or jungle ,args[1] = personCount"); | |
25 | |
26 if (args[0].equals("mongo")) | |
27 PerformanceCheckMongo(Integer.valueOf(args[1])); | |
28 else if (args[0].equals("jungle")) | |
29 // PerformanceCheckJungle(Integer.valueOf(args[1])); | |
30 System.out.println("end"); | |
31 | |
32 | |
33 } | |
34 | |
35 private static void PerformanceCheckJungle(Integer personCount) throws ParserConfigurationException, IOException, SAXException, InterruptedException { | |
36 JuGrix jugrix = extendXmlTree.createJuGrix(true, personCount); | |
37 ReadJungleThread readThread = new ReadJungleThread(jugrix); | |
38 readThread.start(); | |
39 Thread.sleep(10000); | |
40 readThread.set(false); | |
41 System.out.println("findCount = " + readThread.getFindCount()); | |
42 } | |
43 | |
44 private static void PerformanceCheckMongo(int PersonCount) throws InterruptedException { | |
45 MongoClient client = new MongoClient("localhost", 27017); | |
46 client.setWriteConcern(WriteConcern.JOURNALED); | |
47 client.dropDatabase("mydb"); | |
48 MongoDatabase database = client.getDatabase("mydb"); | |
49 MongoCollection<Document> coll = database.getCollection("Persons"); | |
50 for (int personCount = 0; personCount < Integer.valueOf(PersonCount); personCount++) { | |
51 Document person = new Document("Personid", "p:" + String.valueOf(personCount)) | |
52 .append("type", "Person") | |
53 .append("accountId", "a:" + String.valueOf(personCount)) | |
54 .append("lastName", "金川").append("name", "金川竜己") | |
55 .append("nameReading", "かながわたつきくん") | |
56 .append("roleRefIds" | |
57 , new Document("roleRefId", "r:3") | |
58 .append("roleRefId", "r:3")) | |
59 .append("parentOrganizations" | |
60 , new Document("type", "OrganizationMappedByRole") | |
61 .append("OrganizationMappedByRole", | |
62 Arrays.asList( | |
63 new Document("type", "OrganizationMappedByRole") | |
64 .append("organizationRefId", "o:2") | |
65 .append("roleRefId", "r:10") | |
66 , new Document("type", "OrganizationMappedByRole") | |
67 .append("organizationRefId", "o:4") | |
68 .append("roleRefId", "r:14"))) | |
69 ).append("priorities", | |
70 new Document("type", "PriorityMappedByRole") | |
71 .append("PriorityMappedByRole" | |
72 , Arrays.asList( | |
73 new Document("type", "PriorityMappedByRole") | |
74 .append("priority", "0") | |
75 .append("roleRefId", "r:10") | |
76 , new Document("type", "PriorityMappedByRole") | |
77 .append("priority", "1") | |
78 .append("roleRefId", "r:14"))) | |
79 ); | |
80 coll.insertOne(person); | |
81 } | |
82 coll.createIndex(new Document("Personid", 1)); | |
83 System.out.println("insertEnd"); | |
84 ReadMongoThread th = new ReadMongoThread(coll); | |
85 th.start(); | |
86 Thread.sleep(10000); | |
87 th.set(false); | |
88 System.out.println("findCount = " + th.getFindCount()); | |
89 } | |
90 | |
91 } |