# HG changeset patch
# User one
# Date 1417968483 -32400
# Node ID 89478f2ea07f96e7363795e8e8c4bc72d32823b1
# Parent 047bbe8940058ede056e7e2c82b110a1fd100f22
change src name TimeMeasurementJuGrix to TimeMeasurementJuGrixFunction
diff -r 047bbe894005 -r 89478f2ea07f .classpath
--- a/.classpath Sat Dec 06 12:00:21 2014 +0900
+++ b/.classpath Mon Dec 08 01:08:03 2014 +0900
@@ -1,14 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
diff -r 047bbe894005 -r 89478f2ea07f src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/FunctionThread.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/FunctionThread.java Sat Dec 06 12:00:21 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/FunctionThread.java Mon Dec 08 01:08:03 2014 +0900
@@ -9,44 +9,47 @@
public class FunctionThread extends Thread {
- JungleTree tree;
- int findCount;
- boolean loop = true;
+ JungleTree tree;
+ int findCount;
+ boolean loop = true;
- public FunctionThread(JungleTree tree) {
- this.tree = tree;
- this.findCount = 0;
- }
+ public FunctionThread(JungleTree tree) {
+ this.tree = tree;
+ this.findCount = 0;
+ }
- public int getFindCount() {
- return findCount;
- }
+ public int getFindCount() {
+ return findCount;
+ }
+
+ public void set(boolean loop) {
+ this.loop = loop;
+ }
- public void set(boolean loop) {
- this.loop = loop;
- }
-
- @Override
- public void run() {
- while (loop) {
-
- Random rnd = new Random();
- String value = String.valueOf(rnd .nextInt(1000));
- InterfaceTraverser traverser = tree.getTraverser(true);
- Iterator resultIterator = traverser.find((TreeNode node) -> {
- String nodeValue = node.getAttributes().getString("KEY");
- if (nodeValue == null)
- return false;
- if (nodeValue.equals(value))
- return true;
- return false;
- }, "KEY", "3");
+ @Override
+ public void run() {
+ while (loop) {
+
+ findCount++;
+ Random rnd = new Random();
- for (; resultIterator.hasNext();) {
- resultIterator.next();
- }
+ String value = String.valueOf(rnd.nextInt(1000));
+ InterfaceTraverser traverser = tree.getTraverser(true);
+ Iterator resultIterator = traverser.find(
+ (TreeNode node) -> {
+ String nodeValue = node.getAttributes()
+ .getString("KEY");
+ if (nodeValue == null)
+ return false;
+ if (nodeValue.equals(value))
+ return true;
+ return false;
+ }, "KEY", value);
- findCount++;
+ for (; resultIterator.hasNext();) {
+ resultIterator.next();
+ }
+
+ }
}
- }
}
diff -r 047bbe894005 -r 89478f2ea07f src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrix.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrix.java Sat Dec 06 12:00:21 2014 +0900
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-package jp.ac.u_ryukyu.ie.cr.tatsuki.xml;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.Random;
-
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.xml.sax.SAXException;
-
-import jp.ac.u_ryukyu.cr.ie.tatsuki.bbs.JuGrix;
-import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode;
-import jp.ac.u_ryukyu.ie.cr.tatsuki.jungle.store.index.ParentIndex;
-
-public class TimeMeasurementJuGrix {
-
- static int roopCount = 1;
- static boolean useIndex = true;
-
- public static void main(String args[]) throws FileNotFoundException, ParserConfigurationException, SAXException,
- IOException {
- System.out.println("start : ");
-
- String orgId = "o:2";
- String personId = "p:1";
- LinkedList filterIds = new LinkedList();
- filterIds.add("r:5");
- long t2;
- long t1;
- t1 = System.currentTimeMillis();
- JuGrix jugrix = extendXmlTree.createJuGrix(useIndex);
- t2 = System.currentTimeMillis();
- System.out.println("create tree =" + (t2 - t1) + "s");
- Random random = new Random();
-
- t1 = System.currentTimeMillis();
- functions(jugrix, orgId, personId, filterIds);
- t2 = System.currentTimeMillis();
- System.out.println("1回目=" + (t2 - t1) + "s");
-
- long sumTime = 0;
- for (int count = 0; count < roopCount; count++) {
-
- int ran = random.nextInt(30);
- orgId = "o:" + String.valueOf(ran);
- personId = "p:" + String.valueOf(ran);
- t1 = System.currentTimeMillis();
- functions(jugrix, orgId, personId, filterIds);
- t2 = System.currentTimeMillis();
- sumTime = (t2 - t1);
- System.out.println(count + "回目=" + sumTime + "s");
- }
- System.out.println("平均 = " + sumTime + "s");
- System.out.println("end");
- }
-
- private static void functions(JuGrix jugrix, String orgId, String personId, LinkedList filterIds) {
- long t1 = System.currentTimeMillis();
- jugrix.childOrganizationIds(orgId, filterIds);
- long t2 = System.currentTimeMillis();
- // System.out.println("childOrganizationIds = " + (t2-t1));
- jugrix.competentRoleId(personId);
- long t3 = System.currentTimeMillis();
- // System.out.println("competentRoleId = " +(t3-t2));
- jugrix.concurrentRoleIds(personId);
- long t4 = System.currentTimeMillis();
- // System.out.println("concurrentRoleIds = "+(t4-t3));
- jugrix.deepChildOrganizationIds(orgId, filterIds);
- long t5 = System.currentTimeMillis();
- // System.out.println("deepChildOrganizationIds = "+(t5-t4));
- jugrix.deepChildOrganizationIdsPlus(orgId, filterIds);
- long t6 = System.currentTimeMillis();
- // System.out.println("deepChildOrganizationIdsPlus = "+(t6-t5));
- jugrix.deepParentOrganizationIds(orgId, filterIds);
- long t7 = System.currentTimeMillis();
- // System.out.println("deepParentOrganizationIds = "+(t7-t6));
- jugrix.deepParentOrganizationIdsPlus(orgId, filterIds);
- long t8 = System.currentTimeMillis();
- // System.out.println("deepParentOrganizationIdsPlus = "+(t8-t7));
- jugrix.deepPersonIds(orgId, filterIds);
- long t9 = System.currentTimeMillis();
- // System.out.println("deepPersonIds = "+(t9-t8));
- jugrix.isActive(personId);
- long t10 = System.currentTimeMillis();
- // System.out.println("isActive = "+(t10-t9));
- jugrix.parentOrganizationIds(orgId, filterIds);
- long t11 = System.currentTimeMillis();
- // System.out.println("parentOrganizationIds = "+(t11-t10));
- jugrix.personIds(orgId, filterIds);
- long t12 = System.currentTimeMillis();
- // System.out.println("personIds = "+(t12-t11));
- jugrix.roleDescriptionElementIds(orgId, filterIds);
- long t13 = System.currentTimeMillis();
- // System.out.println("roleDescriptionElementIds = "+(t13-t12));
- jugrix.roleIds(orgId, filterIds);
- long t14 = System.currentTimeMillis();
- // System.out.println("roleIds = "+(t14-t13));
- jugrix.rolePriority(personId, "r:34");
- long t15 = System.currentTimeMillis();
- // System.out.println("rolePriority = "+(t15-t14));
- jugrix.stringPathToId("r:path:エスアールエルテクノシステム/臨検システム部/業務システムグループ");
- long t16 = System.currentTimeMillis();
- // System.out.println("stringPathToId = "+(t16-t15));
- }
-}
diff -r 047bbe894005 -r 89478f2ea07f src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrixFunction.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrixFunction.java Mon Dec 08 01:08:03 2014 +0900
@@ -0,0 +1,104 @@
+package jp.ac.u_ryukyu.ie.cr.tatsuki.xml;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.Random;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.xml.sax.SAXException;
+
+import jp.ac.u_ryukyu.cr.ie.tatsuki.bbs.JuGrix;
+
+public class TimeMeasurementJuGrixFunction {
+
+ static int roopCount = 10;
+ static boolean useIndex = true;
+ static int personCount = 300;
+
+ public static void main(String args[]) throws FileNotFoundException,
+ ParserConfigurationException, SAXException, IOException {
+
+ System.out.println("start : ");
+
+ String orgId = "o:2";
+ String personId = "p:1";
+ LinkedList filterIds = new LinkedList();
+ filterIds.add("r:5");
+ long t2;
+ long t1;
+ t1 = System.currentTimeMillis();
+ JuGrix jugrix = extendXmlTree.createJuGrix(useIndex, personCount);
+ t2 = System.currentTimeMillis();
+ System.out.println("create tree =" + (t2 - t1) + "s");
+ Random random = new Random();
+
+ functions(jugrix, orgId, personId, filterIds);
+
+ long sumTime = 0;
+ for (int count = 0; count < roopCount; count++) {
+
+ int ran = random.nextInt(30);
+ orgId = "o:" + String.valueOf(ran);
+ personId = "p:" + String.valueOf(ran);
+ t1 = System.currentTimeMillis();
+ functions(jugrix, orgId, personId, filterIds);
+ t2 = System.currentTimeMillis();
+ sumTime = (t2 - t1) + sumTime;
+ System.out.println(count + "回目=" + sumTime + "s");
+ }
+ System.out.println("平均 = " + (sumTime / 10) + "s");
+ System.out.println("end");
+ }
+
+ private static void functions(JuGrix jugrix, String orgId, String personId,
+ LinkedList filterIds) {
+ long t1 = System.currentTimeMillis();
+ jugrix.childOrganizationIds(orgId, filterIds);
+ long t2 = System.currentTimeMillis();
+ // System.out.println("childOrganizationIds = " + (t2-t1));
+ jugrix.competentRoleId(personId);
+ long t3 = System.currentTimeMillis();
+ // System.out.println("competentRoleId = " +(t3-t2));
+ jugrix.concurrentRoleIds(personId);
+ long t4 = System.currentTimeMillis();
+ // System.out.println("concurrentRoleIds = "+(t4-t3));
+ jugrix.deepChildOrganizationIds(orgId, filterIds);
+ long t5 = System.currentTimeMillis();
+ // System.out.println("deepChildOrganizationIds = "+(t5-t4));
+ jugrix.deepChildOrganizationIdsPlus(orgId, filterIds);
+ long t6 = System.currentTimeMillis();
+ // System.out.println("deepChildOrganizationIdsPlus = "+(t6-t5));
+ jugrix.deepParentOrganizationIds(orgId, filterIds);
+ long t7 = System.currentTimeMillis();
+ // System.out.println("deepParentOrganizationIds = "+(t7-t6));
+ jugrix.deepParentOrganizationIdsPlus(orgId, filterIds);
+ long t8 = System.currentTimeMillis();
+ // System.out.println("deepParentOrganizationIdsPlus = "+(t8-t7));
+ jugrix.deepPersonIds(orgId, filterIds);
+ long t9 = System.currentTimeMillis();
+ // System.out.println("deepPersonIds = "+(t9-t8));
+ jugrix.isActive(personId);
+ long t10 = System.currentTimeMillis();
+ // System.out.println("isActive = "+(t10-t9));
+ jugrix.parentOrganizationIds(orgId, filterIds);
+ long t11 = System.currentTimeMillis();
+ // System.out.println("parentOrganizationIds = "+(t11-t10));
+ jugrix.personIds(orgId, filterIds);
+ long t12 = System.currentTimeMillis();
+ // System.out.println("personIds = "+(t12-t11));
+ jugrix.roleDescriptionElementIds(orgId, filterIds);
+ long t13 = System.currentTimeMillis();
+ // System.out.println("roleDescriptionElementIds = "+(t13-t12));
+ jugrix.roleIds(orgId, filterIds);
+ long t14 = System.currentTimeMillis();
+ // System.out.println("roleIds = "+(t14-t13));
+ jugrix.rolePriority(personId, "r:34");
+ long t15 = System.currentTimeMillis();
+ // System.out.println("rolePriority = "+(t15-t14));
+ jugrix.stringPathToId("r:path:エスアールエルテクノシステム/臨検システム部/業務システムグループ");
+ long t16 = System.currentTimeMillis();
+ // System.out.println("stringPathToId = "+(t16-t15));
+ }
+}
diff -r 047bbe894005 -r 89478f2ea07f src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Sat Dec 06 12:00:21 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Mon Dec 08 01:08:03 2014 +0900
@@ -14,58 +14,65 @@
public class TransactionPerSecondMeasurement {
- static int THREAD_COUNT = 2;
+ public static void main(String[] args) throws InterruptedException {
- public static void main(String[] args) throws InterruptedException {
+ Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(
+ new DefaultTraverser()));
+ JungleTree tree = jungle.createNewTree("testTree");
+ JungleTreeEditor editor = tree.getTreeEditor();
+ editor = createTree(0, new DefaultNodePath(), editor);
+ editor = editor.success().b();
- FunctionThread thread[];
- thread = new FunctionThread[THREAD_COUNT];
+ for (int THREAD_COUNT = 1; THREAD_COUNT < 12; THREAD_COUNT++) {
+ FunctionThread thread[];
+ thread = new FunctionThread[THREAD_COUNT];
+ for (int count = 0; THREAD_COUNT > count; count++) {
+ thread[count] = new FunctionThread(tree);
+ }
- Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser()));
- JungleTree tree = jungle.createNewTree("testTree");
- JungleTreeEditor editor = tree.getTreeEditor();
- editor = createTree(0, new DefaultNodePath(), editor);
- editor = editor.success().b();
-
+ System.out.println("StartThread");
+ for (int count = 0; THREAD_COUNT > count; count++) {
+ thread[count].start();
+ }
- for (int count = 0; THREAD_COUNT > count; count++) {
- thread[count] = new FunctionThread(tree);
- }
+ for (int count = 0; count < 4; count++) {
+ Thread.sleep(2500);
+ // editor = editor.putAttribute(new DefaultNodePath(), key,
+ // ByteBuffer.wrap("2".getBytes())).b();
+ // editor = editor.success().b();
+ }
+ int readCount = 0;
+ for (int count = 0; THREAD_COUNT > count; count++) {
+ readCount = readCount + thread[count].getFindCount();
+ thread[count].set(false);
+ System.out.println(thread[count].getFindCount());
+ }
- System.out.println("StartThread");
- for (int count = 0; THREAD_COUNT > count; count++) {
- thread[count].start();
+ System.out.println(THREAD_COUNT + "readCount = " + readCount);
+ }
+ System.out.println("end");
}
- Thread.sleep(1000);
- // editor = editor.putAttribute(new DefaultNodePath().add(0), key, ByteBuffer.wrap("2".getBytes())).b();
- // editor = editor.success().b();
- Thread.sleep(1000);
- // editor = editor.putAttribute(new DefaultNodePath().add(0), key, ByteBuffer.wrap("2".getBytes())).b().success().b();
- Thread.sleep(1000);
- for (int count = 0; THREAD_COUNT > count; count++) {
- System.out.println(thread[count].getFindCount());
- }
+ static String key = "KEY";
- }
-
- static String key = "KEY";
-
- public static JungleTreeEditor createTree(int deep, NodePath path, JungleTreeEditor editor) {
+ public static JungleTreeEditor createTree(int deep, NodePath path,
+ JungleTreeEditor editor) {
- Random rnd = new Random();
- String value1 = String.valueOf(rnd.nextInt(1000));
- String value2 = String.valueOf(rnd.nextInt(1000));
- editor = editor.addNewChildAt(path, 0).b();
- editor = editor.putAttribute(path.add(0), key, ByteBuffer.wrap(value1.getBytes())).b();
- editor = editor.addNewChildAt(path, 1).b();
- editor = editor.putAttribute(path.add(0), key, ByteBuffer.wrap(value2.toString().getBytes())).b();
- deep++;
+ Random rnd = new Random();
+ String value1 = String.valueOf(rnd.nextInt(1000));
+ String value2 = String.valueOf(rnd.nextInt(1000));
+ editor = editor.addNewChildAt(path, 0).b();
+ editor = editor.putAttribute(path.add(0), key,
+ ByteBuffer.wrap(value1.getBytes())).b();
+ editor = editor.addNewChildAt(path, 1).b();
+ editor = editor.putAttribute(path.add(0), key,
+ ByteBuffer.wrap(value2.toString().getBytes())).b();
+ deep++;
- if (deep < 2) {
- editor = createTree(deep, path.add(0), editor);
- editor = createTree(deep, path.add(1), editor);
+ if (deep < 10) {
+ editor = createTree(deep, path.add(0), editor);
+ editor = createTree(deep, path.add(1), editor);
+ }
+ return editor;
}
- return editor;
- }
}
diff -r 047bbe894005 -r 89478f2ea07f src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java Sat Dec 06 12:00:21 2014 +0900
+++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java Mon Dec 08 01:08:03 2014 +0900
@@ -32,9 +32,8 @@
}
- static int personCount = 200;
- public static JuGrix createJuGrix(boolean useIndex) throws ParserConfigurationException, SAXException,
+ public static JuGrix createJuGrix(boolean useIndex,int personCount ) throws ParserConfigurationException, SAXException,
FileNotFoundException, IOException {
Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser()));
JungleTree readXmlTree = jungle.createNewTree("Person");
@@ -50,9 +49,10 @@
editor = extendsTree(editor, orgTree, roleTree, count);
}
editor.success();
- System.out.println("end-------------------------------");
+
int PersonCount = readXmlTree.getRootNode().getChildren().at(0).b().getChildren().size();
System.out.println("PersonCount = " + PersonCount);
+ System.out.println("end-------------------------------");
JuGrix jugrix = new JuGrix(useIndex, readXmlTree, orgTree, roleTree);
return jugrix;
}
@@ -240,7 +240,7 @@
JungleTree tree = jungle.createNewTree(xml);
ReadXmlHandler readXmlHandler = new ReadXmlHandler(tree);
saxParser
- .parse(new FileInputStream("/Users/e115731/workspace/JungleXmlReader/xml/" + xml + ".xml"), readXmlHandler);
+ .parse(new FileInputStream("/Users/one/Documents/workspace/JungleXMLReader/xml/" + xml + ".xml"), readXmlHandler);
return readXmlHandler.getTree();
}