Mercurial > hg > Members > tatsuki > jungle-bench
changeset 13:7c544969d4c9
add TransactionPersocondMeasurement
author | one |
---|---|
date | Wed, 26 Nov 2014 13:00:26 +0900 |
parents | 33b15ef21dcd |
children | 047bbe894005 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/FunctionThread.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrix.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java |
diffstat | 4 files changed, 167 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/FunctionThread.java Wed Nov 26 13:00:26 2014 +0900 @@ -0,0 +1,52 @@ +package jp.ac.u_ryukyu.ie.cr.tatsuki.xml; + +import java.util.Iterator; +import java.util.Random; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.TreeNode; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.InterfaceTraverser; + +public class FunctionThread extends Thread { + + JungleTree tree; + int findCount; + boolean loop = true; + + public FunctionThread(JungleTree tree) { + this.tree = tree; + this.findCount = 0; + } + + public int getFindCount() { + return findCount; + } + + 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<TreeNode> 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"); + + for (; resultIterator.hasNext();) { + resultIterator.next(); + } + + findCount++; + } + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrix.java Wed Nov 26 06:24:25 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TimeMeasurementJuGrix.java Wed Nov 26 13:00:26 2014 +0900 @@ -10,14 +10,16 @@ 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 = 10; - static boolean useIndex = false; - - public static void main(String args[]) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException { + 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"; @@ -25,7 +27,7 @@ LinkedList<String> filterIds = new LinkedList<String>(); filterIds.add("r:5"); long t2; - long t1; + long t1; t1 = System.currentTimeMillis(); JuGrix jugrix = extendXmlTree.createJuGrix(useIndex); t2 = System.currentTimeMillis(); @@ -46,28 +48,59 @@ t1 = System.currentTimeMillis(); functions(jugrix, orgId, personId, filterIds); t2 = System.currentTimeMillis(); - sumTime = (t2 - t1); - System.out.println(count + "回目=" +sumTime + "s"); + 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<String> 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)); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/TransactionPerSecondMeasurement.java Wed Nov 26 13:00:26 2014 +0900 @@ -0,0 +1,71 @@ +package jp.ac.u_ryukyu.ie.cr.tatsuki.xml; + +import java.nio.ByteBuffer; +import java.util.Random; + +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.DefaultJungle; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.NodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultTreeEditor; +import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.traverser.DefaultTraverser; + +public class TransactionPerSecondMeasurement { + + static int THREAD_COUNT = 2; + + public static void main(String[] args) throws InterruptedException { + + FunctionThread thread[]; + thread = new FunctionThread[THREAD_COUNT]; + + 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(); + + + for (int count = 0; THREAD_COUNT > count; count++) { + thread[count] = new FunctionThread(tree); + } + + System.out.println("StartThread"); + for (int count = 0; THREAD_COUNT > count; count++) { + thread[count].start(); + } + + 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"; + + 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++; + + if (deep < 2) { + editor = createTree(deep, path.add(0), editor); + editor = createTree(deep, path.add(1), editor); + } + return editor; + } +}
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java Wed Nov 26 06:24:25 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/xml/extendXmlTree.java Wed Nov 26 13:00:26 2014 +0900 @@ -32,24 +32,25 @@ } - static int personCount = 10; + static int personCount = 200; public static JuGrix createJuGrix(boolean useIndex) throws ParserConfigurationException, SAXException, FileNotFoundException, IOException { Jungle jungle = new DefaultJungle(null, "hoge", new DefaultTreeEditor(new DefaultTraverser())); JungleTree readXmlTree = jungle.createNewTree("Person"); - // JungleTree readXmlTree = readXml("Person", jungle); + //JungleTree readXmlTree = readXml("Person", jungle); JungleTree orgTree = readXml("Organization", jungle); JungleTree roleTree = readXml("Role", jungle); JungleTreeEditor editor = readXmlTree.getTreeEditor(); NodePath path = new DefaultNodePath(); editor = editor.addNewChildAt(path, 0).b(); editor = editor.putAttribute(path.add(0), "element", ByteBuffer.wrap("Persons".getBytes())).b(); + System.out.println("Create Tree-------------------------------"); for (int count = 0; count < personCount; ++count) { editor = extendsTree(editor, orgTree, roleTree, count); - System.out.println("Count = " + count); } editor.success(); + System.out.println("end-------------------------------"); int PersonCount = readXmlTree.getRootNode().getChildren().at(0).b().getChildren().size(); System.out.println("PersonCount = " + PersonCount); JuGrix jugrix = new JuGrix(useIndex, readXmlTree, orgTree, roleTree);